Repository navigation
[Feature] Validate resource_dict using pydantic #933
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
eb889b1
[Fix] Validate resource_dict using pydantic
jan-janssen 222b3d8
Format black
pyiron-runner 7d7017f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4726c5b
type fixes
jan-janssen 5692ec3
fix
jan-janssen f4cfbe9
fix warnings
jan-janssen 56ca546
fix warning
jan-janssen 412f7b0
add validation test
jan-janssen 5feafc0
fix test
jan-janssen 2891b04
learn from jules
jan-janssen 24b5814
fix import in test
jan-janssen 9f98e8b
handle tests on windows
jan-janssen 1b21e68
test validation error is raised
jan-janssen a8a8295
validate resource_dict
jan-janssen c992ce4
fix validation
jan-janssen 6d9de38
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fbcc8dc
Add cache_key to resource_dict
jan-janssen 532c30e
Merge branch 'pydantic' of github.com:pyiron/executorlib into pydantic
jan-janssen 53f3afd
reduce available keys in resource_dict
jan-janssen 3018f6e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] dc77712
always validate resource dict variable
jan-janssen 01cbcff
include slurm_cmd_args in validation
jan-janssen d7f5178
Merge branch 'main' into pydantic
jan-janssen d6ed7c4
fix restart limit check
jan-janssen aab7930
update documentation
jan-janssen ee1eb34
Add remark about pydantic validation
jan-janssen a9d5fe4
update documentation
jan-janssen 5f39e92
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a742f12
Merge branch 'main' into pydantic
jan-janssen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,5 @@ dependencies: | |
| - jupyter-book =1.0.0 | ||
| - mpi4py =4.1.1 | ||
| - python =3.12 | ||
| - pydantic =2.12.4 | ||
| - pyzmq =27.1.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import warnings | ||
| from typing import Optional | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
||
|
|
||
| class ResourceDictValidation(BaseModel): | ||
| cores: Optional[int] = None | ||
| threads_per_core: Optional[int] = None | ||
| gpus_per_core: Optional[int] = None | ||
| cwd: Optional[str] = None | ||
| num_nodes: Optional[int] = None | ||
| exclusive: Optional[bool] = None | ||
| error_log_file: Optional[str] = None | ||
| restart_limit: Optional[int] = None | ||
| run_time_limit: Optional[int] = None | ||
| priority: Optional[int] = (None,) | ||
| openmpi_oversubscribe: Optional[bool] = (None,) | ||
| pmi_mode: Optional[str] = (None,) | ||
| flux_executor_nesting: Optional[bool] = (None,) | ||
| flux_log_files: Optional[bool] = (None,) | ||
| run_time_limit: Optional[int] = (None,) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| slurm_cmd_args: Optional[list[str]] = None | ||
|
|
||
|
|
||
| def validate_resource_dict(resource_dict: dict) -> None: | ||
| _ = ResourceDictValidation(**resource_dict) | ||
|
|
||
|
|
||
| def validate_resource_dict_with_optional_keys(resource_dict: dict) -> None: | ||
| accepted_keys = ResourceDictValidation.model_fields.keys() | ||
| optional_lst = [key for key in resource_dict if key not in accepted_keys] | ||
| validate_dict = { | ||
| key: value for key, value in resource_dict.items() if key in accepted_keys | ||
| } | ||
| _ = ResourceDictValidation(**validate_dict) | ||
| warnings.warn( | ||
| f"The following keys are not recognized and cannot be validated: {optional_lst}" | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.