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

enable loading config.yml files from URL #3977

Merged
merged 1 commit into from
Jun 2, 2020

Conversation

ltalirz
Copy link
Member

@ltalirz ltalirz commented Apr 28, 2020

In the view of the plans of starting online repositories that maintain
yaml configuration files for computers and codes, it becomes very useful
to be able to directly import a configuration file from a URL.

Todo:

  • write a test

@ltalirz ltalirz marked this pull request as draft April 28, 2020 07:52
@ltalirz ltalirz force-pushed the config-from-url branch 6 times, most recently from 9bf0c03 to aa3c2ee Compare April 28, 2020 09:39
@ltalirz ltalirz force-pushed the config-from-url branch 2 times, most recently from bf6ea84 to 5c29bfc Compare June 1, 2020 23:20
@ltalirz ltalirz requested a review from unkcpz June 1, 2020 23:20
@ltalirz ltalirz marked this pull request as ready for review June 1, 2020 23:21
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

hi @ltalirz ,

First of all, thanks for letting me participate in the code review. I can really learn a lot from it. I made some specific change requests below.
One thing need to be discussed is whether it is possible to provide a valid url somewhere and add test cases for actually test UrlPath and UrlFile?

aiida/cmdline/params/types/__init__.py Outdated Show resolved Hide resolved
aiida/cmdline/params/options/__init__.py Outdated Show resolved Hide resolved
tests/cmdline/commands/test_import.py Outdated Show resolved Hide resolved
aiida/cmdline/params/types/path.py Outdated Show resolved Hide resolved
aiida/cmdline/params/types/path.py Outdated Show resolved Hide resolved
aiida/cmdline/params/types/path.py Outdated Show resolved Hide resolved
@ltalirz ltalirz force-pushed the config-from-url branch 2 times, most recently from 923c7c6 to 0c4137b Compare June 2, 2020 07:43
@ltalirz
Copy link
Member Author

ltalirz commented Jun 2, 2020

Thanks a lot for your review @unkcpz !

One thing need to be discussed is whether it is possible to provide a valid url somewhere and add test cases for actually test UrlPath and UrlFile?

You are absolutely correct.
I had actually added this test but somehow I managed to mess up what was pushed to github and the code got lost (I'm still puzzled as to what I did..).
So, let's just say that the missing test was an exercise for you as a reviewer and that you passed the test ;-)
I have added it back again and addressed the other issues you pointed out.

P.S. Don't worry about the failing test of circleci

@ltalirz ltalirz requested a review from unkcpz June 2, 2020 07:47
@ltalirz ltalirz force-pushed the config-from-url branch 2 times, most recently from 263f93b to 801fe59 Compare June 2, 2020 07:50
docs/source/verdi/verdi_user_guide.rst Outdated Show resolved Hide resolved
.pre-commit-config.yaml Show resolved Hide resolved
@unkcpz
Copy link
Member

unkcpz commented Jun 2, 2020

Thanks a lot @ltalirz , just few questions from my personal side.

You haven't put any more traps in it to test me, have you? 😆

@ltalirz
Copy link
Member Author

ltalirz commented Jun 2, 2020

@unkcpz Please have another look and review again - pushing changes dismisses a previous approving review (just in case this was not clear)

unkcpz
unkcpz previously approved these changes Jun 2, 2020
Copy link
Member

@unkcpz unkcpz left a comment

Choose a reason for hiding this comment

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

It seems all fine. Thanks! @ltalirz

@ltalirz
Copy link
Member Author

ltalirz commented Jun 2, 2020

@chrisjsewell @sphuber The circleci tests are failing and blocking me from merging this PR.
Are they to be taken seriously?

@ltalirz
Copy link
Member Author

ltalirz commented Jun 2, 2020

Ah no, sorry - it seems @unkcpz's review does not yet "count". Will fix this :-)

@ltalirz
Copy link
Member Author

ltalirz commented Jun 2, 2020

@chrisjsewell @sphuber
While Jason's review is now counted, I still can't merge this PR because of the failing CircleCI test (ci/circleci: docs is required to pass in the branch protection rules).
So I'm back to my original question: Are these tests to be taken seriously? If not, why are they required to pass?
The test failure seems to be independent of this PR.

@chrisjsewell
Copy link
Member

@ltalirz there is no config.yaml available for circleci until #4141 is merged

@sphuber
Copy link
Contributor

sphuber commented Jun 2, 2020

I am in the process of merging the docs revamp now. Please hold off with this PR until then. You can then rebase and the tests should then automatically start running

@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #3977 into develop will decrease coverage by 0.01%.
The diff coverage is 94.29%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3977      +/-   ##
===========================================
- Coverage    78.75%   78.74%   -0.00%     
===========================================
  Files          467      467              
  Lines        34454    34466      +12     
===========================================
+ Hits         27130    27138       +8     
- Misses        7324     7328       +4     
Flag Coverage Δ
#django 70.67% <94.29%> (-<0.01%) ⬇️
#sqlalchemy 71.54% <94.29%> (-<0.01%) ⬇️
Impacted Files Coverage Δ
aiida/cmdline/params/types/path.py 90.77% <93.34%> (-1.53%) ⬇️
aiida/cmdline/commands/cmd_import.py 77.50% <100.00%> (ø)
aiida/cmdline/params/options/config.py 100.00% <100.00%> (ø)
aiida/common/extendeddicts.py 93.62% <100.00%> (ø)
aiida/engine/daemon/client.py 72.58% <0.00%> (-1.14%) ⬇️

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 a427699...56dabd0. Read the comment docs.

@sphuber sphuber added the pr/on-hold PR should not be merged label Jun 2, 2020
@sphuber
Copy link
Contributor

sphuber commented Jun 2, 2020

I put this on hold because I am also going through a review, so please don't merge this yet

Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @ltalirz

tests/cmdline/params/types/test_path.py Outdated Show resolved Hide resolved
tests/cmdline/params/types/test_path.py Outdated Show resolved Hide resolved
@@ -17,7 +17,7 @@

from aiida.cmdline.commands.cmd_verdi import verdi
from aiida.cmdline.params import options
from aiida.cmdline.params.types import GroupParamType, ImportPath
from aiida.cmdline.params.types import GroupParamType, PathURL
Copy link
Contributor

Choose a reason for hiding this comment

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

Two points about the name:

  1. I did not immediately understand that this type basically allows a 'Path' or 'URL'. But that is the only reason for its existence, since we have options that need to support both and Click does not support parameters of multiple type. So I think perhaps the name PathOrUrl and FileOrUrl would make this a lot easier to see.
  2. Second point is already made implicitly in the previous. It is a matter of convention, but both Microsoft and Google advocate to stick to camel-case (or pascal-case) rules, even when it comes to acronyms. So URL should become Url.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah... I guess what you would really want is to be able to pass multiple types, but that's not how the click API is built.
Besides concatenating Class names with Or, one can also just choose one of them (e.g. File). In that case, one then has to check the documentation to know exactly how our File implementation differs from the standard one.
Anyhow, I've used your suggestions for now. Just not entirely sure about the FILEORURL metavar... I guess it's good enough for the moment.

In the view of the plans of starting online repositories that maintain
yaml configuration files for computers and codes, it becomes very useful
to be able to directly import a configuration file from a URL.

Version 0.6 of the config-file-option now respects the `type` parameter,
and file handles can be passed directly to the configuration file
provider.
This allows handling opening files locally and from URLs on the same
footing.
@ltalirz
Copy link
Member Author

ltalirz commented Jun 2, 2020

Very strange pre-commit failure https://github.com/aiidateam/aiida-core/pull/3977/checks?check_run_id=731694434

Anyhow, I'm silencing the pre-commit warning now

@sphuber sphuber merged commit e9a3e95 into aiidateam:develop Jun 2, 2020
@sphuber
Copy link
Contributor

sphuber commented Jun 2, 2020

Thanks @ltalirz and @unkcpz !

@sphuber sphuber deleted the config-from-url branch June 2, 2020 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/on-hold PR should not be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants