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

Consolidate WLM functions #199

Merged
merged 20 commits into from
May 25, 2022
Merged

Conversation

MattToast
Copy link
Member

This PR consolidates user facing functions specific to a workload manager in a new smartsim.wlm module. This is done by:

  • Deprecating smartsim.slurm. Now when this module is imported a depreciation warning is displayed. All functionality previously there has been moved to smartsim.wlm.slurm
  • For Slurm and PBS, the following methods have been created for obtaining information about an allocation: get_hosts, get_queue, get_tasks, and get_tasks_per_node. These can be accessed in smartsim.wlm.slurm and smartsim.wlm.pbs respectively.
  • In smartsim.wlm: get_hosts, get_queue, get_tasks, and get_tasks_per_nodemethods have also been created to which will detect and then use the appropriate implementation (slurm/PBS) to allow for portable SmartSim scripts.
  • Tests have been created to allow for check the correctness of the new functionality. In order for the test suite to be able to check that the consolidation functions are obtaining correct information about the current allocation, a user may set the SMARTSIM_TEST_ALLOC_SPEC_SHEET_PATH environment variable to a path to a json file containing information about the current allocation. Example spec sheets are found in tests/test_configs/alloc_spec_sheet_examples/. If this variable is not set or a key is missing from the allocation spec sheet, the test suite will simply call the methods and ensure that no exceptions arise.

@MattToast MattToast requested a review from al-rigazzi May 17, 2022 23:15
@MattToast MattToast linked an issue May 17, 2022 that may be closed by this pull request
7 tasks
Copy link
Collaborator

@al-rigazzi al-rigazzi left a comment

Choose a reason for hiding this comment

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

A couple of comments, otherwise looks really good!

conftest.py Outdated
@pytest.fixture(scope="session")
def alloc_specs():
specs = {}
spec_sheet_path = os.getenv("SMARTSIM_TEST_ALLOC_SPEC_SHEET_PATH", None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a function in this file which prints the value of all SMARTSIM_TEST_... variables. Can you add this variable to it? It will be useful for logging purposes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call! I remember seeing that and then totally forgot to add the new envvar there.

Added SMARTSIM_TEST_ALLOC_SPEC_SHEET_PATH to print_test_configuration at 32e2378

"`smartsim.slurm` has been deprecated and will be removed in a future release.\n"
"Please update your code to use `smartsim.wlm.slurm`"
)
warn(msg, category=DeprecationWarning, stacklevel=2)
Copy link
Collaborator

Choose a reason for hiding this comment

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

As stacklevel=2 is correct, I vaguely remember you pointing out in some other portions of the code, this was set incorrectly. Would it be possible for you to go and update those occurrences? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

No problem! Added at 32e2378

@@ -0,0 +1,118 @@
import os
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not to be overly nitpicking, but can we use a more descriptive name for this file? Something more along the lines of test_wlm_helper_functions.py? I think consolidation_functions is defined within the scope of this PR, but not too much elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not overly nitpicking at all! I was a little weary on the name myself. I like the name test_wlm_helper_functions.py as is so I changed it to that!!

Rename test_consolidation_functions.py -> test_wlm_helper_functions.py at 32e2378

 - Update additional calls to warn w/ stacklevel=2
 - Print the used alloc spec sheet path
 - Give a better name for the new test file
@MattToast MattToast requested a review from al-rigazzi May 23, 2022 18:50
@codecov-commenter
Copy link

codecov-commenter commented May 23, 2022

Codecov Report

Merging #199 (32e2378) into develop (3c25f14) will increase coverage by 1.15%.
The diff coverage is 43.24%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #199      +/-   ##
===========================================
+ Coverage    83.02%   84.17%   +1.15%     
===========================================
  Files           58       58              
  Lines         3263     3242      -21     
===========================================
+ Hits          2709     2729      +20     
+ Misses         554      513      -41     
Impacted Files Coverage Δ
smartsim/database/orchestrator.py 84.87% <ø> (-0.35%) ⬇️
smartsim/wlm/__init__.py 43.24% <43.24%> (ø)
smartsim/entity/dbobject.py 87.87% <0.00%> (ø)
smartsim/_core/launcher/taskManager.py 82.24% <0.00%> (+2.36%) ⬆️
smartsim/entity/dbnode.py 66.03% <0.00%> (+24.94%) ⬆️

Copy link
Collaborator

@al-rigazzi al-rigazzi left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the comments. I think there is just a conflict to fix, but otherwise LGTM!

Great work!

@MattToast MattToast merged commit 4bd5e23 into CrayLabs:develop May 25, 2022
@MattToast MattToast deleted the cons-wlm-funcs branch May 25, 2022 19:20
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.

Consolidate WLM functions
3 participants