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

Basic support for dependencies #5

Merged
merged 7 commits into from
Apr 5, 2023
Merged

Basic support for dependencies #5

merged 7 commits into from
Apr 5, 2023

Conversation

richfitz
Copy link
Member

@richfitz richfitz commented Apr 4, 2023

As with the previous PRs, mostly fairly straightforward I hope. Major issues are:

  • detection of a "safe" location to copy files into. We need this for global resources too.
  • we can probably be more relaxed about what we pull from the arguments to the dependency function, particularly handling around the query parameter, but that can be done later I think
  • not sold on orderly_depends; this could have been orderly_use_dependency perhaps. It might make sense to review all the names in one go?

@richfitz richfitz marked this pull request as ready for review April 4, 2023 16:45
@richfitz richfitz requested review from r-ash and hillalex April 4, 2023 16:45
@richfitz richfitz mentioned this pull request Apr 4, 2023
Copy link
Contributor

@r-ash r-ash left a comment

Choose a reason for hiding this comment

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

Looks good, one comment about an additional test but could also leave that for a separate PR

Comment on lines +1 to +2
orderly3::orderly_depends("explicit", "latest", c(graph.png = "mygraph.png"))
orderly3::orderly_artefact("Final plot", "graph.png")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test case where the name of the dependency is different from the artefact? Ran into an issue with this in orderly2 which is what vimc/orderly2#8 is addressing. Could also do that in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this example the dependency is being renamed, but there's no "unexpected files" check yet here (it'll be a bit harder to add). Or is it something else that's missing in the orderly2 test?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the name of the dependency after being pulled into this report run is different from the name of the artefact. They are the same here as you say. Though actually if we have no unexpected files check here then comment above is not relevant!

@r-ash r-ash merged commit a73db4f into epic-poc Apr 5, 2023
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(orderly_artefact)
export(orderly_depends)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the most consistent with the other function names would be orderly_dependency

Copy link
Member Author

Choose a reason for hiding this comment

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

done in #9

##'
##' @return Undefined
##' @export
orderly_depends <- function(name, query, use) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like it would be nice if you could just do function(name, query, ...) where ... is the named file arguments.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but here's the pair of issues issue with that:

First, In the case where you want to compute the filenames passing in dots is hard as R does not have a spread/splat operator. This will be an issue for Pete's case where we are pulling in things from different regions and renaming them as what we can do with an explicit use argument is:

for (r in regions) {
  query <- rlang::expr(parameter:region == !!r)
  use <- setNames("data.rds", file.path("data", paste0(r, ".rds")))
  orderly_depends("data", query, use)
}

Second, you can compromise by adding a get collisions with names, so we could write:

orderly_depends <- function(name, query, ..., use = c(...)) {
}

or by carefully processing ..., but this requires some care with any analysis of the contents in static_orderly_dependency I think.

I had a look at sorting this out but it looks complicated enough that I'd rather kick it down the road a bit

Copy link
Member Author

Choose a reason for hiding this comment

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

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