Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DESCRIPTION file #231

Merged
merged 8 commits into from
Feb 2, 2024
Merged

add DESCRIPTION file #231

merged 8 commits into from
Feb 2, 2024

Conversation

cjyetman
Copy link
Member

No description provided.

@jdhoffa
Copy link
Member

jdhoffa commented Jan 31, 2024

Hmmm NB but this makes me a bit nervous. Are you planning to convert this into an R package?

Relates to RMI/practices#2

@cjyetman cjyetman mentioned this pull request Jan 31, 2024
@cjyetman
Copy link
Member Author

cjyetman commented Jan 31, 2024

Hmmm NB but this makes me a bit nervous. Are you planning to convert this into an R package?

This is towards the suggestion by @AlexAxthelm (can't remember exactly where) to use some standard R package structure even in our "workflow" repos when they contain R code

@jdhoffa
Copy link
Member

jdhoffa commented Jan 31, 2024

Hmmm... well I would much prefer if we postpone this until after tomorrow's Dev Hangouts, where we can brainstorm and hash out this pacta.* and workflow.* conversation once and for all.

Part of the reason we made the split in the first place was that PACTA_analysis was half package and half workflow, and it made it an absolute nightmare to manage, and this feels like a big step back into that direction @AlexAxthelm

Are we cool to pause this and discuss it next DevHangouts?

See proposed next steps here: RMI/practices#2 (comment)

@jdhoffa
Copy link
Member

jdhoffa commented Jan 31, 2024

Then, once we're all on the same page, we can proceed?

@cjyetman
Copy link
Member Author

Are we cool to pause this and discuss it next DevHangouts?

sure, but see for example https://github.com/RMI-PACTA/workflow.pacta for this setup in use

@jdhoffa
Copy link
Member

jdhoffa commented Jan 31, 2024

Are we cool to pause this and discuss it next DevHangouts?

sure, but see for example https://github.com/RMI-PACTA/workflow.pacta for this setup in use

I saw it there as well, and it made me nervous there as well XD

@cjyetman
Copy link
Member Author

Oddly, renv::dependencies() returns R as a package because of the minimum version R dependency listed in DESCRIPTION, which then breaks the build script because it wants to install an R package named R. That could easily be worked around by removing the specification in DESCRIPTION.

@jdhoffa
Copy link
Member

jdhoffa commented Jan 31, 2024

Oddly, renv::dependencies() returns R as a package because of the minimum version R dependency listed in DESCRIPTION, which then breaks the build script because it wants to install an R package named R. That could easily be worked around by removing the specification in DESCRIPTION.

I'm not against it honestly! Just lots of signs pointing towards "we should discuss and document the differences between pacta.* and workflow.* sooner than later", otherwise I fear we're going to end up with a whole zoo of repositories again

Who knows, maybe we just decide that everything we code must be an R package and leave it at that ¯_(ツ)_/¯

@cjyetman
Copy link
Member Author

Oddly, renv::dependencies() returns R as a package because of the minimum version R dependency listed in DESCRIPTION, which then breaks the build script because it wants to install an R package named R. That could easily be worked around by removing the specification in DESCRIPTION.

opened an issue with {renv}

@cjyetman cjyetman marked this pull request as draft January 31, 2024 14:41
@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

opened an issue with {renv}

wow, and it's resolved already! 😄

jdhoffa
jdhoffa previously approved these changes Feb 1, 2024
Copy link
Member

@jdhoffa jdhoffa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our parallel discussion:
(which was more or less "we sort of know what pacta.* is but not really what workflow.* is)

I approve this. I don't think it makes sense to be restrictive on a workflow.* since we can't even define it :-D

AlexAxthelm
AlexAxthelm previously approved these changes Feb 1, 2024
@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

So, adding a DESCRIPTION file here breaks our Dockerfile because it uses renv::dependencies('$WORKFLOW_DIR')[['Package']] to determine what packages are needed to install. I was actually expecting that @jdhoffa and @AlexAxthelm would be very happy about that (defining the R pkg dependencies in a standardized, structured way, rather than letting renv::dependencies() magically determine them by parsing the R scripts), but ironically renv::dependencies(), when parsing a DESCRIPTION file, currently includes the minimum R version needed as an R package, which would then require parsing that out I guess. I submitted and issue with renv and it's already been fixed (😱), but not yet CRAN released and anyway I think maybe it's not a great idea to rely on having a bleeding edge version of renv to facilitate this, so I think I'm going to drop this idea (for now at least) and close this PR.

So to recap... my preferred solution would be:

  1. use renv::dependencies('DESCRIPTION')[['Package']] in the Dockerfile to restrict the "magic" of renv to using the DESCRIPTION as the exclusive list of dependencies
  2. but since renv::dependencies() currently (and presumably all previous versions) would require parsing out "R" as a package name, this probably isn't worth it

@jdhoffa
Copy link
Member

jdhoffa commented Feb 1, 2024

  1. use renv::dependencies('DESCRIPTION')[['Package']] in the Dockerfile to restrict the "magic" of renv to using the DESCRIPTION as the exclusive list of dependencies
  2. but since renv::dependencies() currently (and presumably all previous versions) would require parsing out "R" as a package name, this probably isn't worth it

Could we not just scrap using renv, and do something like:

# Copy DESCRIPTION
COPY DESCRIPTION /workflow.transition.monitor/DESCRIPTION

# install R package dependencies
RUN Rscript -e "pak::local_install_deps(root = '/workflow.transition.monitor');"

@jdhoffa
Copy link
Member

jdhoffa commented Feb 1, 2024

Or sorry, am I misunderstanding, and you would prefer to not do it that way, and to instead use renv?

I'm just a little confused haha

@AlexAxthelm
Copy link
Collaborator

Could we not just scrap using renv, and do something like:

NB: this is pretty much exactly what's happening with the newer Docker images i'm maintaining

https://github.com/RMI-PACTA/workflow.factset/blob/59ebf3a113a9a512de61784ea2920136c6171574/Dockerfile#L50-L56

@jdhoffa
Copy link
Member

jdhoffa commented Feb 1, 2024

Could we not just scrap using renv, and do something like:

NB: this is pretty much exactly what's happening with the newer Docker images i'm maintaining

https://github.com/RMI-PACTA/workflow.factset/blob/59ebf3a113a9a512de61784ea2920136c6171574/Dockerfile#L50-L56

Yeah I believe that's the easiest way

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

Interesting... I tried with pak::local_deps(root = '.') (to just get the list of needed dependencies but not install them) which failed because of our "remote" GitHub packages, but pak::local_install_deps(root = '.') appears to work. I might have to experiment with that a bit to convince myself it will work properly in a different environment.

@AlexAxthelm
Copy link
Collaborator

Also note that pak looks at Remotes in DESCRIPTION, and can call from GH repos. See the one in workflow.portfolio.parsing, where I'm using that to grab pacta.portfolio.import, and the non-CRAN version of jsonvalidate.

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

At least in the current setup here, pak::local_install_deps(root = '.') is still a problem, because we

  1. get a list of all packages required
  2. remove our private GH hosted pkgs from that list
  3. add our private GH hosted pkgs using parameterized tags to specific versions of those pkgs
  4. then install the list

So if pak::local_deps(root = '.') worked as expected, we could maybe do all that with just pak and no renv, but it doesn't seem to, at least not on my machine.

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

add-DESCRIPTION > pak::local_deps()
Error:
! ! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* local::.:
  * Can't install dependency pacta.executive.summary
  * Can't install dependency pacta.portfolio.allocate
  * Can't install dependency pacta.portfolio.audit
  * Can't install dependency pacta.portfolio.import
  * Can't install dependency pacta.portfolio.report
  * Can't install dependency pacta.portfolio.utils
* pacta.executive.summary: Can't find package called pacta.executive.summary, pacta.portfolio.allocate, pacta.portfolio.audit, pacta.portfolio.import, pacta.portfolio.report, pacta.portfolio.utils.
* pacta.portfolio.allocate: Can't find package called pacta.executive.summary, pacta.portfolio.allocate, pacta.portfolio.audit, pacta.portfolio.import, pacta.portfolio.report, pacta.portfolio.utils.
* pacta.portfolio.audit: Can't find package called pacta.executive.summary, pacta.portfolio.allocate, pacta.portfolio.audit, pacta.portfolio.import, pacta.portfolio.report, pacta.portfolio.utils.
* pacta.portfolio.import: Can't find package called pacta.executive.summary, pacta.portfolio.allocate, pacta.portfolio.audit, pacta.portfolio.import, pacta.portfolio.report, pacta.portfolio.utils.
* pacta.portfolio.report: Can't find package called pacta.executive.summary, pacta.portfolio.allocate, pacta.portfolio.audit, pacta.portfolio.import, pacta.portfolio.report, pacta.portfolio.utils.
* pacta.portfolio.utils: Can't find package called pacta.executive.summary, pacta.portfolio.allocate, pacta.portfolio.audit, pacta.portfolio.import, pacta.portfolio.report, pacta.portfolio.utils.
Run `rlang::last_trace()` to see where the error occurred.

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

ah, maybe I need to add the Remotes to DESCRIPTION first...

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

aargh! Docker build still fails. I think I've seen this kind of thing before... pak fails when a dependent of a dependent depends on a "remote" package. Maybe if I explicitly depend on RMI-PACTA/r2dii.colours?

Copy link

github-actions bot commented Feb 1, 2024

Docker image from this PR (d3b7773) created

docker pull ghcr.io/rmi-pacta/workflow.transition.monitor:pr231

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

@jdhoffa and @AlexAxthelm I got this to work (finally), at least the Docker image build successfully, so could you take another close look at the diff please? After all that, I feel like I need to test the Docker image too, which I'll do offline tomorrow.

@AlexAxthelm
Copy link
Collaborator

ah, maybe I need to add the Remotes to DESCRIPTION first...

Do note that if you do this, pak grabs the HEAD from the GH repo (for us that's main). I don't know of a good way to install specific refs, without resorting to something like what we're doing in the dockerfile for this repo (specifying refs with ARG)

@cjyetman
Copy link
Member Author

cjyetman commented Feb 1, 2024

Yeah... in the Dockerfile is the only place pak::local_deps() is being used, and it strips out all the "RMI-PACTA/*" packages before adding in references to the relevant PACTA pkgs with the specific refs attached

@jdhoffa
Copy link
Member

jdhoffa commented Feb 2, 2024

ah, maybe I need to add the Remotes to DESCRIPTION first...

Do note that if you do this, pak grabs the HEAD from the GH repo (for us that's main). I don't know of a good way to install specific refs, without resorting to something like what we're doing in the dockerfile for this repo (specifying refs with ARG)

I'm not sure how pak works (as a more-or-less superseding of devtools), but I think in devtools you could specify a branch/ commit using the usual GH syntax? I can have a look today.

Comment on lines +48 to +54
Remotes:
RMI-PACTA/pacta.executive.summary,
RMI-PACTA/pacta.portfolio.allocate,
RMI-PACTA/pacta.portfolio.audit,
RMI-PACTA/pacta.portfolio.import,
RMI-PACTA/pacta.portfolio.report,
RMI-PACTA/pacta.portfolio.utils
Copy link
Member

@jdhoffa jdhoffa Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB (more of a question really, and not something we should solve in this PR): but I wonder if it would be possible/ interesting/ useful to just add or specify our R-universe instance as a package repository? so install from CRAN or RMI R-Universe. that way we don't need to jump through weird Remotes loops, the Dockerfile just knows that anything in our R-universe is valid to install. (obviously we would still need to sort out how to specify what version to install, but I think that is doable)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is another cool possibility with r-universe (adding r-universe as one of your CRAN mirrors), but... I'm not sure if/how it works specifying a pkg in DESCRIPTION (probably still have to use Remotes:).

Copy link
Member

@jdhoffa jdhoffa Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, really? I would guess that if functions as a CRAN mirror, then install.packages() would know to look there, meaning packages installed via DESCRIPTION would automatically be found without Remotes...

(I would guess that, I have no idea if that's the case)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +119 to +120
workflow_pkgs <- pak::local_deps(root = '$WORKFLOW_DIR')[['ref']]; \
workflow_pkgs <- grep('^RMI-PACTA[/]|^local::.$', workflow_pkgs, value = TRUE, invert = TRUE); \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks awesome! Exactly what I had in mind :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having to add ^local::.$ to prevent it from trying to install the "local package" is a bit weird, but yeah, otherwise works pretty good

Copy link
Member

@jdhoffa jdhoffa Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's part of what my initial hesitancy was with adding a DESCRIPTION file to the workflow.* repo in the first place.

You are essentially stating "this is an R package", so of course most tools will think of it now as a package.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pak starts the dependency tree at the root package (every package is dependent on itself, it seems).

@cjyetman cjyetman marked this pull request as ready for review February 2, 2024 07:32
@cjyetman cjyetman merged commit dddec2e into main Feb 2, 2024
1 check passed
@cjyetman cjyetman deleted the add-DESCRIPTION branch February 2, 2024 07:32
cjyetman added a commit that referenced this pull request Feb 2, 2024
This PR does all the appropriate things related to adding a license to
the repo, including:
- adding a LICENSE file
- adding a LICENSE.md file
- properly specifying the license in the DESCRIPTION file

depends on #231
@cjyetman
Copy link
Member Author

cjyetman commented Feb 9, 2024

Hmmm NB but this makes me a bit nervous. Are you planning to convert this into an R package?

This is towards the suggestion by @AlexAxthelm (can't remember exactly where) to use some standard R package structure even in our "workflow" repos when they contain R code

@jdhoffa I finally found the suggestion I was referring to: RMI-PACTA/workflow.data.preparation#77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants