-
Notifications
You must be signed in to change notification settings - Fork 12
started implementing slurm job submission from the gui #114
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
Draft
skarakuzu
wants to merge
6
commits into
NSLS2:HXN_development
Choose a base branch
from
skarakuzu:slurm_job_submission
base: HXN_development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee93a00
started implementing slurm job submission from the gui
skarakuzu f587581
change source file
skarakuzu 42d9dda
job summission and deletion works but orion-api still directs the job…
skarakuzu ad38171
changed submission. now can get jobid status and also cancel. to be c…
skarakuzu ecaed30
clean a bit more and fix GUI abort issue
skarakuzu 233100f
cleanup and fix user HOME retrieval
skarakuzu 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
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 |
|---|---|---|
|
|
@@ -10,6 +10,10 @@ | |
| import traceback | ||
| import time | ||
|
|
||
|
|
||
| import requests | ||
| import json | ||
|
|
||
| from .databroker_api import load_metadata, save_data | ||
| from .utils import use_mpi_machinefile, set_flush_early | ||
| from .ptycho.utils import save_config | ||
|
|
@@ -98,7 +102,37 @@ def clear_slurm_header(self): | |
| os.remove(slurm_header) | ||
| except: | ||
| pass | ||
|
|
||
|
|
||
| def submit_job(self): | ||
| url = "https://orion-api-staging.nsls2.bnl.gov/api/v1/compute/orion/jobs" | ||
| bearer_token = os.getenv("SLURM_JWT") | ||
|
|
||
| payload = { | ||
| "script": "#!/bin/bash -l\n" | ||
| "#SBATCH --job-name=trial\n" | ||
| "#SBATCH --time=0-00:10:00\n" | ||
| "#SBATCH --nodes=1\n" | ||
| "#SBATCH --ntasks-per-node=2\n" | ||
| "#SBATCH --error=%x.err\n" | ||
| "#SBATCH --output=%x.out\n\n" | ||
| "module purge\n" | ||
| "module load beamline-aliases\n\n" | ||
| "source load-hxn\n\n" | ||
| "srun python solve.py", | ||
| "environment": ["PATH=/usr/bin:/bin:/usr/sbin:/sbin", "SLURM_EXPORT_ENV=ALL"], | ||
| "working_dir_path": "/nsls2/users/skarakuzu1/orion_ptycho" | ||
| } | ||
|
|
||
| print(payload) | ||
| headers = { | ||
| "Content-Type": "application/json", | ||
| "Authorization": f"Bearer {bearer_token}" | ||
| } | ||
|
|
||
| response = requests.post(url, headers=headers, json=payload) | ||
|
||
| print("response is ", response) | ||
|
|
||
|
|
||
| def recon_remote(self, param:Param, update_fcn=None): | ||
|
|
||
| self.fname_full = os.path.join(self.remote_path,'ptycho_'+str(param.scan_num)+'_'+param.sign) | ||
|
|
@@ -119,6 +153,9 @@ def recon_remote(self, param:Param, update_fcn=None): | |
|
|
||
| self.return_value = 0 # Assume the recon will succeed unless later detects failure and modify it. | ||
|
|
||
| print("Submitting job from the gui") | ||
| self.submit_job() | ||
|
|
||
| # try: | ||
| time.sleep(1) | ||
| out = self.msg.readlines() | ||
|
|
@@ -157,7 +194,7 @@ def recon_remote(self, param:Param, update_fcn=None): | |
| # pass | ||
|
|
||
| def run(self): | ||
| print('Ptycho thread started') | ||
| print('Ptycho thread started helloooo***') | ||
| try: | ||
| self.recon_remote(self.param, self.update_signal.emit) | ||
| except IndexError: | ||
|
|
||
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.
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 this evolves, it's worth keeping an eye on whether this actually needs any instance state (i.e.
self.<X>). If not, it could just be a simple function, rather than a method, and that would make it simpler to test.