-
Notifications
You must be signed in to change notification settings - Fork 230
Migrate Transport
to use pydantic for configuration
#6198
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
base: main
Are you sure you want to change the base?
Conversation
6f4e549
to
0909304
Compare
c30af1f
to
d606a83
Compare
Is it worth to tag this with a v3.0.0 milestone where we could introduce such breaking changes? |
The breaking changes are actually quite minimal. I don't remember by heart, but it may be just the order in which options are prompted for and some other minimal things. Mostly the changes are just in implementation. And I am not sure if there actually ever will be a v3 😅 There are no concrete plans for now in any case. But definitely worth a discussion at some point perhaps. |
d606a83
to
aa42fd7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6198 +/- ##
==========================================
+ Coverage 79.13% 79.16% +0.04%
==========================================
Files 565 565
Lines 43391 43428 +37
==========================================
+ Hits 34331 34376 +45
+ Misses 9060 9052 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0c5f715
to
1d0fab2
Compare
@agoscinski @khsrali working on this one. Rebased on |
@agoscinski do we want to add model testing for transport similar to that of the orm module? |
@agoscinski maybe check that last commit regarding the non-interactive option for the localhost config. I guess this wasn't an issue before due to loose code but now is due to Seb's updates. We use UpdateAdding |
|
911b43e
to
9bcf7e7
Compare
@khsrali can you give a look to the new |
c109b61
to
1965318
Compare
@khsrali please review 🙏 |
I apologize @edan-bainglass This was a super busy week.. now I'm out on a vacation, and don't have my laptop with me.. It's quite painful to review with my phone 🥲 Will be back to work on Tuesday the 20th. P.S. also Alex is on vacation, so I think this can wait from the release point of view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't check the changes in cmd_computer, carefully.
I have to check if we have complete test suits for that.
echo.echo_success(f'Computer `{label}` {"and all its associated nodes " if associated_nodes_pk else ""}deleted.') | ||
|
||
|
||
class LazyConfigureGroup(VerdiCommandGroup): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this change is related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of @sphuber's original work. It seems now more standard w.r.t the way the code command is handled, which was already using pydantic I think since the abstract code refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is the case, but re-instating the LazyConfigureGroup
class breaks the TestVerdiComputerConfigure.test_ssh_interactive
test. The values passed to the CLI command are somehow out of order and redundant, leading to the following nonsense:
Report: enter ? for help.
Report: enter ! to ignore the default and set no value.
User name [edanb]:
Port number [22]:
Look for keys [Y/n]: some_remote_user <- ?
Error: invalid input
Look for keys [Y/n]: 345
Error: invalid input
Look for keys [Y/n]: no
SSH key file []:
Connection timeout in s [60]:
Allow ssh agent [Y/n]:
SSH proxy jump []:
SSH proxy command []:
Compress file transfers [Y/n]:
GSS auth [False]:
GSS kex [False]:
GSS deleg_creds [False]:
GSS host [localhost]:
Load system host keys [Y/n]:
Key policy (RejectPolicy, WarningPolicy, AutoAddPolicy) [RejectPolicy]:
Use login shell when executing command [Y/n]:
Connection cooldown time (s) [30.0]:
Report: Configuring computer test_ssh_interactive for user test@localhost.
Success: test_ssh_interactive successfully configured for test@localhost
instead of the correct
Report: enter ? for help.
Report: enter ! to ignore the default and set no value.
Use login shell when executing command [Y/n]:
Connection cooldown time (s) [30.0]:
User name [edanb]: some_remote_user
Port number [22]: 345
Look for keys [Y/n]: no
SSH key file []:
Connection timeout (s) [60]:
Allow ssh agent [y/N]:
SSH proxy jump []:
SSH proxy command []:
Compress file transfers [Y/n]:
GSS auth [y/N]:
GSS kex [y/N]:
GSS deleg_creds [y/N]:
GSS host []:
Load system host keys [Y/n]:
Key policy (RejectPolicy, WarningPolicy, AutoAddPolicy) [RejectPolicy]:
Report: Configuring computer test_ssh_interactive for user test@localhost.
Success: test_ssh_interactive successfully configured for test@localhost
At the moment, it's not clear what broke this part. I suppose @sphuber encountered this and fixed it. Unfortunately (uncharacteristically) not documented 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I got it. Digging into the run_cli_command
fixture, I see that the user_input
argument (a string providing user input to the tested command) can include new line characters to simulate the interactive prompt, i.e., pressing enter to accept defaults. This was changed in the original PR to support the CLI changes - two initial \n
lead to accepting the default user name and port, which in turn assigns the user_input
username and port to the wrong fields. Removing these passes the test 👍
), | ||
] | ||
|
||
class Model(AsyncTransport.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the previous stuff are also kept?
Line 75-110
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, this is unrelated. The "previous stuff" is used in the CLI. However, still to be discussed is if that should remain, or if we use the model. If possible, good if we don't mess with the current UX, which informs the user of issues when they occur. The use of pydantic models will likely defer notification of issues until the end of the CLI process. Not ideal or friendly.
), | ||
] | ||
|
||
class Model(BaseModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same question here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
# set up localhost computer | ||
verdi computer setup --non-interactive --config "${CONFIG}/localhost.yaml" | ||
verdi computer configure core.local localhost --config "${CONFIG}/localhost-config.yaml" | ||
verdi computer configure core.local localhost --non-interactive --config "${CONFIG}/localhost-config.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this was not needed before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update:
@edan-bainglass reports he cannot configure a computer even with this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could also potentially mean that, the tests we have in place are not adequate to capture that failure.
@edan-bainglass can you please tailor the error you get?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original PR, the configure_computer
function in cmd_computer.py expected a non_interactive
positional argument. It is unclear why @sphuber had added this. It is not used in the body of the function. Also, in other similar functions (see cmd_code.py), the non_interactive
option is wrapped up in kwargs
and is not explicitly defined as a positional argument. Removing the non_interactive
argument from configure_computer
resolves the issue I was encountering.
As for --non-interactive
not being included in the original command referenced in this comment, that is unclear. It was included when configuring the slurm computer.
@sphuber I pinged you on at least one comment regarding the original work. However, it would be great if you could provide a description to this PR briefly detailing the motivation and summarizing the changes. |
…onsistency There are no additional fields. This is just a reference to the parent `Transport.Model`. Still best to follow the hierarchical chain for consistency.
401dee6
to
d93c679
Compare
@khsrali @agoscinski we need to revisit the UpdateAll good. I found the cause of the failure. However, I also found |
@agoscinski note that in this PR, I no longer use the dynamic class. Using the original lazy class, with the dynamic class use pushed to another PR (soon to be opened). |
6b85f04
to
30596b6
Compare
b23417c
to
3d8d1fb
Compare
3d8d1fb
to
ac9bd11
Compare
@agoscinski @khsrali I think perhaps we were wrong to remove the changes to the CLI. Unlike the ORM pydantic models introduced in #6842, this PR introduces pydantic models to the Transport classes solely for use in the CLI. Not sure if @sphuber expected more of them (e.g., serialization), but in this PR, no such mechanism is introduced. The serialization mechanics introduced in #6842 are limited to Entity subclasses, of which the Transport module is not a part of. So there is no straight forward (de)serialization here. If the above is accurate, I would close #6924 and reintroduce the CLI changes here, then add a test that the model is operational, whatever that means. Comments? |
@khsrali let's discuss this soon, if you have time. I'd like to close this and resolve the pydantic work. |
Following #6255, we introduce here pydantic models also to the Transport module for use in configuring computers.