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

Patch core's configuration to allow get from global scope #86

Merged
merged 1 commit into from
Jul 18, 2022
Merged

Conversation

mih
Copy link
Member

@mih mih commented Jul 18, 2022

...without requiring a dataset to be present.

This patch replaces both frontend functions for configuration, because
the input validation checks are not sufficiently modularized for a
more surgical patch. Two key changes are made:

  1. The unnecessary prevention of a get without a dataset around is
    removed, and the documentation is adjusted.
  2. The configuration() function now selects the appropriate config
    manager based on the ds argument value alone, rather than
    implementing additional cross-comparison with the scope argument.
    Such argument validation is not done in Configuration.__call__()
    alone.

Closes datalad/datalad#6854

...without requiring a dataset to be present.

This patch replaces both frontend functions for `configuration`, because
the input validation checks are not sufficiently modularized for a
more surgical patch. Two key changes are made:

1) The unnecessary prevention of a `get` without a dataset around is
   removed, and the documentation is adjusted.
2) The `configuration()` function now selects the appropriate config
   manager based on the `ds` argument value alone, rather than
   implementing additional cross-comparison with the `scope` argument.
   Such argument validation is not done in `Configuration.__call__()`
   alone.

Closes datalad/datalad#6854
@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #86 (57efd69) into main (57b85fd) will decrease coverage by 5.29%.
The diff coverage is 96.77%.

@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
- Coverage   93.24%   87.95%   -5.30%     
==========================================
  Files          28       30       +2     
  Lines        2103     2474     +371     
==========================================
+ Hits         1961     2176     +215     
- Misses        142      298     +156     
Impacted Files Coverage Δ
datalad_next/patches/__init__.py 100.00% <ø> (ø)
datalad_next/patches/configuration.py 96.38% <96.38%> (ø)
datalad_next/patches/tests/test_configuration.py 100.00% <100.00%> (ø)
datalad_next/_version.py 45.39% <0.00%> (-54.61%) ⬇️
datalad_next/gitremote/datalad_annex.py 89.50% <0.00%> (+0.27%) ⬆️

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 57b85fd...57efd69. Read the comment docs.

@adswa
Copy link
Member

adswa commented Jul 18, 2022

cool, this works for me 👍

cfg.reload(force=True)


conf_mod.Configuration.__call__ = Configuration.__call__
Copy link
Member

Choose a reason for hiding this comment

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

If you derive from from conf_mod.Configuration, wouldn't it make sense to replace the class rather than just __call__? Or the other way around: derive from Interface as usual?

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 thought so too, but just replacing the class is not enough. You would still need to replace the references to its __call__. When I did this, I ended up in a situation where replacing the class itself no longer has any impact.

Copy link
Member

Choose a reason for hiding this comment

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

I seem to remember I got that way of patching to work at some point. Need to dig. But okay - don't let it be an obstacle for merge. We can "fix" that later.

@mih mih changed the title Patch core's configuration to allow get from global scope Patch core's configuration to allow get from global scope Jul 18, 2022
@mih mih merged commit 8d6ce2c into main Jul 18, 2022
@mih mih deleted the enh-config branch July 18, 2022 16:34
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.

configuration get user.name should work without a dataset
3 participants