-
Notifications
You must be signed in to change notification settings - Fork 5
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
Set the default repo_path inside the get_model_spec function #110
Conversation
… file path to the model spec file used
Pinging @taldcroft @javierggt @jeanconn @matthewdahmer @jskrist (by the way, is it possible for me to be given permission to add reviewers on the right side? Currently I am not allowed) |
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.
Would it make more sense to refactor the code a bit? i.e. extract out the bit of code that does the file globing into a separate public utility function that could be called explicitly, like get_full_spec_file_path(model_name, repo_path)
and then this could be called internally and externally without breaking any APIs.
xija/get_model_spec.py
Outdated
tuple of dict, str, str | ||
Xija model specification dict, chandra_models version, path to model spec | ||
file used |
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.
might as well update the example in the doc string to show this new return value (or add a second example.
Is this change a bugfix that should go into ska3-matlab 2021.7? |
@javierggt I wouldn't call this a bugfix. it's not urgent. It depends on your timeline though. |
I really like @jskrist's idea to factor the file path bit out so we don't have to wreck the API. I'll do that instead. |
Also be aware that it always makes a clone into a temp dir. I didn't look at it very closely but maybe the file path you get will be useless. |
Maybe we just need to log more info about the model used to the screen? |
One more comment on the file name is that the basic philosophy behind all this is that the content is what matters and that it lives in a distributed git repo. So the version tag you get back from that repo (e.g. It probably is not obvious, but you can do somewhat tricky things with this infrastructure. For instance, ACIS could add a brand new model to the repo in a dev branch named
Small note before you try this at home, namely that |
@taldcroft I see the point now and I am reverting the changes in this PR which involve passing back the model path--I left in the change which sets the default |
def get_xija_model_spec(model_name, version=None, repo_path=REPO_PATH, | ||
check_version=False, timeout=5) -> dict: | ||
def get_xija_model_spec(model_name, version=None, repo_path=None, | ||
check_version=False, timeout=5) -> tuple: |
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.
Is this a bug fix (correcting the annotated return type)? I originally though that you were changing the return type of the function, but now I don't see that in the diff. same for Line 95.
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.
Yes, this a bug fix since it already returns a tuple.
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.
Looks good thanks @jzuhone .
Description
This PR makes
two changesone minor change toxija.get_model_spec
.one minor and another that is API-breakingrepo_path
beNone
and then set it toREPO_PATH
internally, so that calling routines from other packages can pass aNone
as default and they won't need to know aboutREPO_PATH
.2. In a couple of cases, I have found that it would be nice to know the path to the JSON file returned byget_model_spec
, so it can be reported in logging or print statements. The way I currently do this is rather clunky--I importREPO_PATH
from the same module. But this duplicates what's already being done in the function and is error-prone if something changes. So this change simply returns the path as the third argument--unfortunately this also breaks API.If anyone can think of a non-API-breaking way to achieve the second change, let me know.