-
Notifications
You must be signed in to change notification settings - Fork 202
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
base: master
Are you sure you want to change the base?
Expose wd
via scheduler
#1571
Conversation
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 unfortunately cannot test this right now: what's the difference between wd
and dirname(expid["file"])
?
Given #1543, adding the canonical usage to the docs would be a great improvement IMHO.
@@ -485,3 +485,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.""" |
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.
wd
should be spelled out if this is part of the user-facing API. Attributes of artiq.master.scheduler.Run
are not documented.
if rid in pipeline.pool.runs: | ||
run = pipeline.pool.runs[rid] | ||
return run.wd | ||
raise KeyError("RID not found") |
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.
Matter of taste: why not?
try:
return pipeline.pool.runs[rid].wd
except KeyError:
raise KeyError("RID not found") # [from None]
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 was going for consistency with check_pause()
, but yeah there's no reason why not
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.
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.
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.
Good point indeed, sorry. Missed one level of indentation.
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.
Probably a moot point anyway as it looks like this PR will be rejected for release-5, and unnecessary for master/future release-6
If the file is in-repository, then
I hadn't seen that issue, but I agree that this might be helpful there, and it's actually pretty similar to the use case I have in mind, although I'm not using the git backend. I'm writing a sort of base class that needs to import other experiments (specified by the user when they implement the class) based on a |
An alternate implementation of this functionality would be to simply add a |
After #1543 (comment) we could just do |
Yes! If the working directory was set to the repository rather than the results directory, I think that would take care of things. Is that a change you plan on introducing into |
No, and this PR would not be eligible for release-5 either. |
Would you consider it for release-5 if I went with this approach instead? Just to make do until we're ready to update to the next release. |
No, we don't introduce new features on |
Understood, thanks! |
@sbourdeauducq I see you have reopened this PR a while ago. Is there a way @b-bondurant can refactor this change to get this functionality into |
Do you still need it if we do #1543? |
I think we would, but I'm not familiar enough with Python's import machinery to be sure. My specific use case is a bit different from those that have been discussed so far in that issue. I'm using Essentially, this class ( class def: https://gitlab.com/duke-artiq/dax/-/blob/master/dax/base/scheduler.py#L693 |
@b-bondurant Since we didn't reach consensus on an alternative approach, let's merge this. Can you address the review items? |
Maybe it is possible to rename the function to |
Signed-off-by: Brad Bondurant <[email protected]>
8b79485
to
ce60806
Compare
@sbourdeauducq what do you think about something like that? It also might be clearer to users since (as @airwoodix pointed out), edit: just to be clear, I ran a local test and |
What happens with experiments submitted "outside the repository"? This corner case is also what is plaguing the other proposals. |
It returns |
And I actually didn't need to do any special handling for that case since I'm just returning |
For git-based repositories (i.e. using |
ARTIQ Pull Request
Description of Changes
Add
get_wd(rid)
method to scheduler and scheduler virtual device. For the use case I have in mind, this would retrieve the repository path when using a filesystem backend, but it could also be useful for retrieving the path of the tmpdir when using the git backend.Hardly a "feature," but not technically a bugfix either.
Signed-off-by: Brad Bondurant [email protected]
Type of Changes
Steps (Choose relevant, delete irrelevant before submitting)
All Pull Requests
git commit --signoff
, see copyright).This does add to the scheduler API, but I wasn't sure if it was significant enough to warrant updating the release notes.
Code Changes
flake8
to check code style (follow PEP-8 style).flake8
has issues with parsing Migen/gateware code, ignore as necessary.Current unit tests pass, no new tests added. Manual testing done with filesystem backend, returns path to repository as expected.
Git Logistics
git rebase --interactive
). Merge/squash/fixup commits that just fix or amend previous commits. Remove unintended changes & cleanup. See tutorial.git show
). Format:Licensing
See copyright & licensing for more info.
ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited and are licensed under LGPLv3+.