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

Change Project constructor to use root directory #706

Merged
merged 3 commits into from
Mar 5, 2022

Conversation

vyasr
Copy link
Contributor

@vyasr vyasr commented Mar 3, 2022

Description

The Project constructor no longer requires a config object. Projects are constructed using a root directory alone.

Motivation and Context

Part of #643. Since projects no longer have ids and are entirely identified by their root directory in signac 2.0, the constructor can be simplified to reflect that.

Types of Changes

  • Documentation update
  • Bug fix
  • New feature
  • Breaking change1

1The change breaks (or has the potential to break) existing functionality.

Checklist:

If necessary:

  • I have updated the API documentation as part of the package doc-strings.
  • I have created a separate pull request to update the framework documentation on signac-docs and linked it here.
  • I have updated the changelog and added all related issue and pull request numbers for future reference (if applicable). See example below.

@vyasr vyasr added the enhancement New feature or request label Mar 3, 2022
@vyasr vyasr added this to the v2.0.0 milestone Mar 3, 2022
@vyasr vyasr requested review from a team as code owners March 3, 2022 23:08
@vyasr vyasr requested review from kidrahahjo and Tobias-Dwyer and removed request for a team March 3, 2022 23:08
@vyasr vyasr self-assigned this Mar 3, 2022
@codecov
Copy link

codecov bot commented Mar 3, 2022

Codecov Report

Merging #706 (7559513) into schema2 (01873a1) will increase coverage by 0.04%.
The diff coverage is 100.00%.

❗ Current head 7559513 differs from pull request most recent head 94759e9. Consider uploading reports for the commit 94759e9 to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           schema2     #706      +/-   ##
===========================================
+ Coverage    86.24%   86.28%   +0.04%     
===========================================
  Files           52       52              
  Lines         5037     5038       +1     
  Branches      1099     1099              
===========================================
+ Hits          4344     4347       +3     
+ Misses         491      490       -1     
+ Partials       202      201       -1     
Impacted Files Coverage Δ
signac/contrib/project.py 89.30% <100.00%> (+0.01%) ⬆️
signac/common/config.py 81.25% <0.00%> (+3.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01873a1...94759e9. Read the comment docs.

signac/contrib/project.py Outdated Show resolved Hide resolved
@@ -1608,7 +1609,7 @@ def get_project(cls, root=None, search=True, **kwargs):
)
)

return cls(config=config, **kwargs)
return cls(root=config["project_dir"], **kwargs)
Copy link
Member

Choose a reason for hiding this comment

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

The current approach finds and loads a project config and then uses its "project_dir" key to construct the Project. Can this be simplified somehow, so that we check for config existence and then pass the root to the constructor? We shouldn't need to load the config twice (in get_project and again in the constructor), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm that's a good point. This question is related to the last piece of #643, which is changing load_config to not populate the project_dir into the config but to instead change load_config to return a tuple of (root_dir, config). The reason I originally wanted to make that change is because actually modifying the contents of the config with something that isn't contained in any of the config files is an unexpected side effect that could cause confusion. Perhaps your question here is an indication that the discovery aspect should be separated into a completely separate function, and that load_config would stop discovering altogether? Alternatively, load_config could still be allowed to discover even if we added a separate discover_config function, but that seems like unnecessary redundancy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bdice let me know what you think here. I can split those changes into a separate PR if that's the direction that we want to go.

Copy link
Member

@bdice bdice Mar 5, 2022

Choose a reason for hiding this comment

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

Yes, it might be a better design to separate discovery from config loading (parsing). A separate PR might be best, I agree.

tests/test_shell.py Outdated Show resolved Hide resolved
@vyasr vyasr requested review from bdice and kidrahahjo March 5, 2022 01:43
@vyasr vyasr mentioned this pull request Mar 5, 2022
12 tasks
@vyasr vyasr merged commit 0070698 into schema2 Mar 5, 2022
@vyasr vyasr deleted the schema/project_constructor branch March 5, 2022 18:20
vyasr added a commit that referenced this pull request Mar 14, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
vyasr added a commit that referenced this pull request Apr 14, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
vyasr added a commit that referenced this pull request Apr 19, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
vyasr added a commit that referenced this pull request Apr 19, 2022
* Initial migration to schema version 2 including config rename (#678)

* Implement initial migration to schema version 2.

* Require project-local config to be signac.rc (not .signacrc) and make searches stricter to match.

* Standardize method for getting project config at a root.

* Move config to .signac/config.

* Fix import order.

* Address PR comments.

* Remove some unnecessary code.

* Address final PR coments.

* Use integer schema version numbers (#688)

* Change schema versioning to use integer strings.

* Switch from int strings to pure ints.

* Update signac/contrib/migration/__init__.py

Co-authored-by: Bradley Dice <[email protected]>

Co-authored-by: Bradley Dice <[email protected]>

* Remove project name from schema (#684)

* Remove project id API.

* Remove project name from config as part of migration.

* Fix issues with config CLI and remove project from default cfg.

* Address PR comments.

* Change the str of a project to the str of its root directory.

* Change Project constructor to use root directory (#706)

* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.

* Move internal signac files into .signac subdirectory (#708)

* Move shell history.

* Move sp_cache file.

* Address PR comments.

* Move discovery to separate functions. (#711)

* Move discovery to separate functions.

* Address first round of PR comments.

* Address PR comments.

* Apply suggestions.

* Remove configurable workspace directory  (#714)

* Remove workspace configurability.

* Implement workspace_dir migration.

* Apply suggestions from code review

Co-authored-by: Bradley Dice <[email protected]>

* Address remaining PR comments.

* Update tests/test_project.py

* Remove mention of configurability from project workspace docstring

* Address PR comments.

Co-authored-by: Bradley Dice <[email protected]>
Co-authored-by: Corwin Kerr <[email protected]>

* Update description of schema migration.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Bradley Dice <[email protected]>
Co-authored-by: Corwin Kerr <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
vyasr added a commit that referenced this pull request Apr 21, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
vyasr added a commit that referenced this pull request May 2, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
bdice pushed a commit that referenced this pull request Jun 14, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
bdice pushed a commit that referenced this pull request Aug 1, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
bdice pushed a commit that referenced this pull request Oct 7, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
bdice pushed a commit that referenced this pull request Oct 27, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
vyasr added a commit that referenced this pull request Oct 30, 2022
* Change project constructor to accept a root directory instead of a config file.

* Change Project repr.

* Address easy PR comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants