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

DM-38492: Support URIs in some additional APIs #813

Merged
merged 7 commits into from Apr 12, 2023
Merged

DM-38492: Support URIs in some additional APIs #813

merged 7 commits into from Apr 12, 2023

Conversation

timj
Copy link
Member

@timj timj commented Apr 3, 2023

It is convenient in some cases if URIs can be supported rather than local files.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Patch coverage: 58.62% and project coverage change: -0.03 ⚠️

Comparison is base (32c9f60) 87.77% compared to head (b2319fb) 87.74%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #813      +/-   ##
==========================================
- Coverage   87.77%   87.74%   -0.03%     
==========================================
  Files         268      268              
  Lines       34937    34930       -7     
  Branches     7347     7346       -1     
==========================================
- Hits        30667    30651      -16     
- Misses       3116     3125       +9     
  Partials     1154     1154              
Impacted Files Coverage Δ
python/lsst/daf/butler/cli/cmd/commands.py 89.51% <ø> (ø)
python/lsst/daf/butler/_butler.py 77.66% <45.45%> (-0.88%) ⬇️
python/lsst/daf/butler/script/ingest_files.py 92.59% <100.00%> (+0.28%) ⬆️
python/lsst/daf/butler/transfers/_context.py 87.27% <100.00%> (ø)
python/lsst/daf/butler/transfers/_interfaces.py 100.00% <100.00%> (ø)
python/lsst/daf/butler/transfers/_yaml.py 87.02% <100.00%> (ø)
tests/test_cliCmdImport.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@timj timj marked this pull request as ready for review April 3, 2023 22:17
@timj timj force-pushed the tickets/DM-38492 branch 2 times, most recently from 0134fa6 to ea8a5bb Compare April 5, 2023 21:16
Copy link
Contributor

@andy-slac andy-slac 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, a couple of minor questions.

Comment on lines 2054 to 2056
`~lsst.daf.butler.Butler.export`. If this a string (name) or
`~lsst.resources.ResourcePath` and is not an absolute path,
does not exist in the current working directory, and ``directory``
is not `None`, it is assumed to be in
``directory``. Defaults to "export.{format}".
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a general though, not related to the changes - this handling of the directory resembles a search path which always includes two entries - cwd and directory. This may cause confusion if an export file can be found in both places but user really wants it to come from directory, as there is no way to remove cwd from a search path. Would it make sense to reverse search path to look in directory first, or have an option to disable search in cwd?

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 think @TallJimbo designed this API. I'm happy to change it to prefer the given directory over cwd if he agrees.

Copy link
Member

Choose a reason for hiding this comment

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

I have no problem changing it. Andy's argument makes sense.

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've changed it to use directory if both cwd and directory have the file. I also issue a warning message in that scenario just in case.

python/lsst/daf/butler/_butler.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/transfers/_context.py Outdated Show resolved Hide resolved
@timj timj force-pushed the tickets/DM-38492 branch 2 times, most recently from c3ff71e to 72a2d0b Compare April 10, 2023 21:15
Click doesn't know how to read remote resources so tell it to
treat the "export file" parameter as a string and then let
ResourcePath deal with it downstream. This also simplifies
the test code.
Can not open as a stream because of DM-38589. Read the entire
file instead up front.
mypy doesn't like this but it does work.
If someone explicitly specifies a directory and that directory
has the export file in it, it seems more likely that that is
the one they really wanted.
Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

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

Re-reviewed once again, looks good.

@timj timj merged commit 54a215b into main Apr 12, 2023
11 of 13 checks passed
@timj timj deleted the tickets/DM-38492 branch April 12, 2023 18:15
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.

None yet

3 participants