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

Expose wd via scheduler #1571

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions artiq/frontend/artiq_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def ccb_issue(service, *args, **kwargs):
"scheduler_request_termination": scheduler.request_termination,
"scheduler_get_status": scheduler.get_status,
"scheduler_check_pause": scheduler.check_pause,
"scheduler_get_wd": scheduler.get_wd,
"ccb_issue": ccb_issue,
})
experiment_db.scan_repository_async()
Expand Down
8 changes: 8 additions & 0 deletions artiq/master/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,11 @@ def check_pause(self, rid):
return False
return r.priority_key() > run.priority_key()
raise KeyError("RID not found")

def get_wd(self, rid):
"""Returns the ``wd`` attribute of the run with the specified RID."""
Copy link
Contributor

Choose a reason for hiding this comment

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

wd should be spelled out if this is part of the user-facing API. Attributes of artiq.master.scheduler.Run are not documented.

for pipeline in self._pipelines.values():
if rid in pipeline.pool.runs:
run = pipeline.pool.runs[rid]
return run.wd
raise KeyError("RID not found")
Copy link
Contributor

@airwoodix airwoodix Dec 22, 2020

Choose a reason for hiding this comment

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

Matter of taste: why not?

try:
    return pipeline.pool.runs[rid].wd
except KeyError:
    raise KeyError("RID not found")  # [from None]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going for consistency with check_pause(), but yeah there's no reason why not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, if you put this whole try/except inside the loop then I don't think it would work since this would raise a key error for every pipeline that doesn't contain that RID, even if there's one that does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point indeed, sorry. Missed one level of indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably a moot point anyway as it looks like this PR will be rejected for release-5, and unnecessary for master/future release-6

7 changes: 7 additions & 0 deletions artiq/master/worker_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def submit(self, pipeline_name=None, expid=None, priority=None, due_date=None, f
make_parent_action("scheduler_request_termination"))
get_status = staticmethod(make_parent_action("scheduler_get_status"))

_get_wd = staticmethod(make_parent_action("scheduler_get_wd"))
@host_only
def get_wd(self, rid=None):
if rid is None:
rid = self.rid
return self._get_wd(rid)


class CCB:
issue = staticmethod(make_parent_action("ccb_issue"))
Expand Down