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

Make registry configurable #132

Merged
merged 15 commits into from
Jan 16, 2024

Conversation

jhiemstrawisc
Copy link
Collaborator

@jhiemstrawisc jhiemstrawisc commented Sep 21, 2023

Add mechanism for passing global configurations

The biggest change in this commit is the addition of src/config.py, which acts as a
singleton module to pass global configs around SPRAS. When the Snakefile is run, it
uses its magically available config to instantiate the config object in the config
module. After instantiation, other modules can import src.config as config, which allows
them to access various config parameters. For example, to access the container framework,
you can do:

import src.config as config
framework = config.config.framework

In addition to modularizing configuration, I also added the ability to specify container
registries and owners in the config. A full container name looks like
docker.io/reedcompbio/pathlinker:latest. The config option considers docker.io the base_url,
reedcompbio the owner, and then pathlinker will be hardcoded by that method. Lacking in this
implementation is the ability to specify exactly what tag to run each PRM against. With the new
config module, that should be relatively simple to add.

As far as implentation choices, since the config module makes various values globally available,
I decided to stop passing some values like singularity down through nested levels of function
calls, and instead get those values close to where they're needed. The only place this was obviously
not the clean way to do this was in the tests -- for now, I toggle config.config.framework in the
places where we need to test singularity.

@jhiemstrawisc
Copy link
Collaborator Author

@agitter This wound up being a bit more like open heart surgery than I anticipated. Let's discuss the approach and decide if we like doing things this way or not.

Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

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

I'm leaving some initial thoughts. I originally didn't envision moving all of the config file to a class, but now I can see benefits to doing that.

config/config.yaml Outdated Show resolved Hide resolved
src/config.py Outdated Show resolved Hide resolved
src/allpairs.py Outdated Show resolved Hide resolved
src/containers.py Outdated Show resolved Hide resolved
src/containers.py Outdated Show resolved Hide resolved
src/util.py Outdated Show resolved Hide resolved
test/AllPairs/test_ap.py Outdated Show resolved Hide resolved
src/containers.py Outdated Show resolved Hide resolved
@jhiemstrawisc jhiemstrawisc force-pushed the make-registry-configurable branch from 41f9ec8 to 1313446 Compare September 29, 2023 19:25
@jhiemstrawisc
Copy link
Collaborator Author

@agitter, I think I've covered all of the things we discussed in our last meeting, and this should more or less be ready for a final review.

@agitter
Copy link
Collaborator

agitter commented Oct 13, 2023

Merging #126 created merge conflicts in this pull request

Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

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

This looks pretty close. I added another round of comments. After those are resolved, I'll run the workflow locally to confirm everything still runs as expected.

src/containers.py Outdated Show resolved Hide resolved
src/config.py Outdated Show resolved Hide resolved
src/allpairs.py Outdated Show resolved Hide resolved
Snakefile Show resolved Hide resolved
Snakefile Outdated Show resolved Hide resolved
src/analysis/cytoscape.py Outdated Show resolved Hide resolved
src/config.py Outdated Show resolved Hide resolved
test/AllPairs/test_ap.py Outdated Show resolved Hide resolved
@jhiemstrawisc jhiemstrawisc force-pushed the make-registry-configurable branch from 8d2d076 to 7ecce69 Compare November 7, 2023 20:49
The biggest change in this commit is the addition of `src/config.py`, which acts as a
singleton module to pass global configs around SPRAS. When the Snakefile is run, it
uses it's magically available `config` to instantiate the config object in the config
module. After instantiation, other modules can `import src.config as config`, which allows
them to access various config parameters. For example, to access the container framework,
you can do:
```
import src.config as config
framework = config.config.framework
```

In addition to modularizing configuration, I also added the ability to specify container
registries and owners in the config. A full container name looks like
`docker.io/reedcompbio/pathlinker:latest`. The config option considers docker.io the base_url,
reedcompbio the owner, and then pathlinker will be hardcoded by that method. Lacking in this
implementation is the ability to specify exactly what tag to run each PRM against. With the new
config module, that should be relatively simple to add.

As far as implentation choices, since the config module makes various values globally available,
I decided to stop passing some values like `singularity` down through nested levels of function
calls, and instead get those values close to where they're needed.
I updated `registry` to `container_registry` in anticipation of a future where we
support different data registries as well, per @agitter's suggestion. I also changed
the `config.framework` variable to `config.container_framework` to be more clear
what this variable is supposed to contain.
This commit moves the container framework up a level so that each algorithm
is called with the configured framework instead of determining the framework
internally. The logic behind this is that doing so makes testing much easier;
instead of messing with global configs in the tests, just call the PRM's run
function with a different framework specified.

This also moves prepare_volume to `containers.py` to fix the issue with importing
hash lengths in the function. Arguably, I should have moved prepare_volume into
containers.py in the first place.
@jhiemstrawisc jhiemstrawisc force-pushed the make-registry-configurable branch from b24ed46 to b6f5f58 Compare December 12, 2023 15:30
Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

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

I went through all the files again, including viewing them in my IDE. This looks very close now. The test cases pass locally, and the workflow produces expected results locally.

images/Dockerfile Outdated Show resolved Hide resolved
Snakefile Show resolved Hide resolved
Snakefile Outdated Show resolved Hide resolved
spras/allpairs.py Outdated Show resolved Hide resolved
spras/analysis/cytoscape.py Outdated Show resolved Hide resolved
spras/containers.py Outdated Show resolved Hide resolved
spras/allpairs.py Outdated Show resolved Hide resolved
test/analysis/test_cytoscape.py Outdated Show resolved Hide resolved
test/analysis/test_summary.py Outdated Show resolved Hide resolved
test/test_config.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@agitter agitter left a comment

Choose a reason for hiding this comment

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

The last commit addresses all of my previous review comments. This final suggestion addresses the new config TODO, adding comments to the class member variables describing them. I'll merge after this change is accepted.

spras/config.py Outdated Show resolved Hide resolved
@agitter agitter merged commit 879f1b5 into Reed-CompBio:master Jan 16, 2024
5 checks passed
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