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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
98aea76
Allow ButlerURI to be created from another ButlerURI
timj Jul 11, 2020
af8e0cc
Switch ButlerConfig.configDir to be a ButlerURI
timj Jul 11, 2020
65ebfc8
Switch config discovery from getPackageDir to pkg_resources
timj Jul 11, 2020
afdaef9
Remove lsst.utils from test_dbAuth
timj Jul 11, 2020
ad4a12b
Add the __init__.py back at top level
timj Jul 11, 2020
1753bda
Create a setup.py to enable test builds with pip
timj Jul 12, 2020
7ecd59e
Ignore files left over from python setup.py build
timj Jul 12, 2020
0210c4f
Allow longer lines in YAML files
timj Jul 12, 2020
d76b6ca
Add an action to build the package and run tests
timj Jul 12, 2020
9ab2646
Explicitly preinstall sphgeom dependencies
timj Jul 12, 2020
acd40da
Fall back to standard safe loader if C yaml library is not found
timj Jul 12, 2020
9d381c6
Add psutil, needed by lsst.utils.tests
timj Jul 12, 2020
e52d6bf
Force installation of sqlite and libyaml-dev
timj Jul 12, 2020
f6c4058
Use ubuntu 20.04 for modern sqlite
timj Jul 12, 2020
9f1d205
Adjust tests for missing arguments to account for click 7.1 change
timj Jul 12, 2020
8a2be95
Install pytest-xdist in workflow to speed up tests
timj Jul 12, 2020
278eb13
Enable doc build in action
timj Jul 12, 2020
cd7a94f
Fix documentation references to DAF_BUTLER_DIR
timj Jul 13, 2020
e80f40f
Change sphgeom URLs to point to master
timj Jul 13, 2020
e098c6d
Fix flake8 problem with blank line
timj Jul 16, 2020
bfefe54
Update setup.py
timj Jul 16, 2020
e3ac45b
Update doc/lsst.daf.butler/configuring.rst
timj Jul 16, 2020
08a12f7
Configure test repo to properly use in-memory registry
timj Jul 17, 2020
d9af50c
Remove support email and license field from setup.cfg
timj Jul 16, 2020
3541962
Add comment on usage of posixpath
timj Jul 16, 2020
de83b86
Expand on S3 not supporting includeConfigs
timj Jul 16, 2020
5ccfb63
Simplify includeConfig search path by using ButlerURI
timj Jul 16, 2020
f2afab2
Enable pytest openfiles checking
timj Jul 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: build_and_test

on:
- push
- pull_request

jobs:
build_and_test:
# runs-on: ubuntu-latest
# Need >= 20.04 for modern sqlite. Can switch to latest when
# github change
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install sqlite
run: sudo apt-get install sqlite libyaml-dev

# It seems like pip install of requirements for a URL package
# does not install those dependencies
- 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.

run: pip install -r requirements.txt

# We have two cores so we can speed up the testing with xdist
- name: Install xdist and openfiles
run: pip install pytest-xdist pytest-openfiles

- name: Build and install
run: pip install -v .

- name: Run tests
run: pytest -r a -v -n 3 --open-files

- 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.

run: pip install documenteer[pipelines]

- name: Build documentation
working-directory: ./doc
run: package-docs build
3 changes: 0 additions & 3 deletions .github/workflows/mypy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
- name: Install
run: pip install mypy

- name: Ensure LSST module root
run: touch python/lsst/__init__.py

- name: Change to source directory and run mypy
working-directory: ./python
run: mypy lsst
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ bin/*
.idea/
.vscode/
mypy.log
build/*
dist/*
python/lsst/utils/*
2 changes: 1 addition & 1 deletion .yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ignore: |
rules:
document-start: {present: false}
line-length:
max: 80
max: 132
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
ignore: |
Expand Down
4 changes: 2 additions & 2 deletions doc/lsst.daf.butler/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The main sections of the YAML file are handled separately by each sub configurat
Each config specialization, registry, schema, storage class, composites, and dimensions knows the name of the key for its own section of the configuration and knows the names of files providing overrides and defaults for the configuration.
Additionally, if the sub configuration contains a ``cls`` key, that class is imported and an additional configuration file name can be provided by asking the class for its defaultConfigFile property.
All the keys within a sub configuration are processed by the class constructed from ``cls``.
The primary source of default values comes from ``$DAF_BUTLER_DIR/config`` –- this directory contains YAML files matching the names specified in the sub config classes and also can include names specified by the corresponding component class (for example `~lsst.daf.butler.datastores.posixDatastore.PosixDatastore` specifies that configuration should be found in ``datastores/posixDatastore.yaml``.
The primary source of default values comes from the ``config`` resource (accessed using `pkg_resources` and package ``lsst.daf.butler``) –- this directory contains YAML files matching the names specified in the sub config classes and also can include names specified by the corresponding component class (for example `~lsst.daf.butler.datastores.posixDatastore.PosixDatastore` specifies that configuration should be found in ``datastores/posixDatastore.yaml``.
There are additional search paths that can be included when a config object is constructed:

1. Explicit list of directory paths to search passed into the constructor.
Expand All @@ -22,7 +22,7 @@ To construct a Butler configuration object (`~lsst.daf.butler.ButlerConfig`) fro
Shell variables will be expanded.
The contents of these files will then be inserted into the configuration at the same hierarchy as the ``includeConfigs`` directive, with priority given to the values defined explicitly in the parent configuration (for lists of include files later files overwrite content from earlier ones).
* Each sub configuration class is constructed by supplying the relevant subset of the global config to the component Config constructor.
* A search path is constructed by concatenating the supplied search path, the environment variable path (``$DAF_BUTLER_CONFIG_PATH``), and the daf_butler config directory (``$DAF_BUTLER_DIR/config``).
* A search path is constructed by concatenating the supplied search path, the environment variable path (``$DAF_BUTLER_CONFIG_PATH``), and the daf_butler config directory (within the ``lsst.daf.butler`` package resource).
* Defaults are first read from the config class default file name (e.g., ``registry.yaml`` for `~lsst.daf.butler.Registry`, and ``datastore.yaml`` for `~lsst.daf.butler.Datastore`) and merged in priority order given in the search path.
Every file of that name found in the search path is read and combined with the others.
* Then any ``cls``-specific config files are read, overriding the current defaults.
Expand Down
2 changes: 2 additions & 0 deletions python/lsst/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
15 changes: 8 additions & 7 deletions python/lsst/daf/butler/_butlerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
"""
Configuration classes specific to the Butler
"""
from __future__ import annotations

__all__ = ("ButlerConfig",)

import copy
import os.path
from typing import (
Optional
)

from .core import (
ButlerURI,
Expand Down Expand Up @@ -68,14 +73,14 @@ class ButlerConfig(Config):

def __init__(self, other=None, searchPaths=None):

self.configDir = None
self.configDir: Optional[ButlerURI] = None

# If this is already a ButlerConfig we assume that defaults
# have already been loaded.
if other is not None and isinstance(other, ButlerConfig):
super().__init__(other)
# Ensure that the configuration directory propagates
self.configDir = other.configDir
self.configDir = copy.copy(other.configDir)
return

if isinstance(other, str):
Expand All @@ -101,11 +106,7 @@ def __init__(self, other=None, searchPaths=None):
configFile = butlerConfig.configFile
if configFile is not None:
uri = ButlerURI(configFile)
if uri.scheme == "s3":
uri.updateFile("")
self.configDir = uri.geturl()
else:
self.configDir = os.path.dirname(os.path.abspath(configFile))
self.configDir = uri.dirname()

# A Butler config contains defaults defined by each of the component
# configuration classes. We ask each of them to apply defaults to
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.