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-15465: Clean up utils usage with a view to supporting test running in pull requests #323

Merged
merged 28 commits into from Jul 17, 2020

Conversation

timj
Copy link
Member

@timj timj commented Jul 11, 2020

  • Removed getPackageDir and replaced with package resources
  • Remove spurious usage of lsst.utils.tests in one test file

Still have many doImport usages and one test uses a getTempFilePath call.

@timj timj force-pushed the tickets/DM-15465 branch 4 times, most recently from 2b0f9f0 to 81eb9d9 Compare July 12, 2020 01:17
@timj timj requested review from TallJimbo and ktlim July 12, 2020 15:06
@timj
Copy link
Member Author

timj commented Jul 12, 2020

This now seems to be passing so that pull requests will run the tests and build the documentation. It takes 8minutes to run and is currently not required for merging. Two minutes of that is building sphgeom so maybe we can upload a wheel as a "GitHub release" and pull that to save some time.

I wonder if we have to reconsider the pull_request and push builds. Are they the same once a pull request has been created?

Copy link
Member

@TallJimbo TallJimbo left a comment

Choose a reason for hiding this comment

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

Only big picture comment is that with all of the conditionals in ButlerURI I wonder if it'd work better as an ABC with separate implementations for remote URIs, POSIX paths, and now pkg_resources. Or maybe a concrete class that delegated to an ABC or something. Probably out of scope for this ticket, but something to think about.

@timj
Copy link
Member Author

timj commented Jul 14, 2020

Regarding ButlerURI returning subclasses for different URI schemes, that does seem worth thinking about. It would also allows the addition of more concrete methods such as "does this item exist" and "download this resource".

doc/lsst.daf.butler/configuring.rst Outdated Show resolved Hide resolved
- name: Run tests
run: pytest -r a -v -n 3

- name: Install documenteer
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for the future: Should package the install and build as an action that others can reuse.

- name: Install sphgeom dependencies
run: pip install -r https://raw.githubusercontent.com/lsst/sphgeom/master/requirements.txt

- name: Install dependencies
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for the future: these four steps (deps, xdist, install ., pytest) could be packaged as an action for others to reuse.

Copy link
Member Author

Choose a reason for hiding this comment

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

An action can import another action?

Copy link
Contributor

Choose a reason for hiding this comment

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

A workflow (which this is) uses actions. I'm saying to package up the run scripts as a reusable action.

setup.cfg Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
python/lsst/daf/butler/core/config.py Show resolved Hide resolved
python/lsst/daf/butler/core/config.py Outdated Show resolved Hide resolved
@@ -140,6 +148,66 @@ def extractFile(self, filename):
return yaml.load(response["Body"], Loader)


@dataclass
class Resource:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to unify filesystem paths or even URIs with these Resource paths so that they appear to the rest of the code as a uniform class instead of having to type-case everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding pkg_resources://lsst.daf.butler/configs/datastore.yaml URI support to ButlerURI might work but really needs ButlerURI to be updated to have concrete methods for checking existence and even opening a stream. I think some of this ties in with @TallJimbo wondering if ButlerURI could be changed so that the constructor returns specialist S3ButlerURI, PosixFileURI and LocalFileURI implementations.

setup.py Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
timj added 14 commits July 16, 2020 15:49
Make use of new APIs in ButlerURI
This required that the configs move inside the python package.
It also needed some cleanup in ButlerURI versus bare paths
and the addition of support to instantiate a Config from
a new Resource class.
No other daf_butler tests include the memory tester
so the usage here was anomalous.
Python really really wants it there and setuptools won't
work without it. It already caused problems with mypy
so put it back.
If lsst.utils is not available locally the files we need
are downloaded.
Not sure why the next line doesn't do this
timj added 3 commits July 16, 2020 16:33
click 7.0 uses double quotes but 7.1 uses a single quote.
For now we support both so switch the code to a regex rather
than a substring match.
timj and others added 7 commits July 16, 2020 16:36
@timj timj merged commit 25a0dad into master Jul 17, 2020
@timj timj deleted the tickets/DM-15465 branch July 17, 2020 04:56
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

4 participants