-
Notifications
You must be signed in to change notification settings - Fork 35
Fixes failure of the embed resolver to find common embed file in package #167
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
Fixes failure of the embed resolver to find common embed file in package #167
Conversation
le_utils/validators/common.py
Outdated
| with open(os.path.join(schema_dir, "definitions-embed_common.json")) as f: | ||
| common_definitions = json.load(f) | ||
| common_definitions = json.loads( | ||
| pkgutil.get_data("le_utils", "resources/embedcommondefinitions.json").decode( |
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 kinda liked the old file name, because it followed the pattern of the existing files. Did it contain disallowed characters?
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 don't think so. I guess it was more of a convention change in the context of the 'resources' folder. Will make the change and test it out.
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.
Made the change--works correctly.
| schema_dir = os.path.join(os.path.dirname(__file__), "..", "..", "spec") | ||
| with open(os.path.join(schema_dir, "definitions-embed_common.json")) as f: | ||
| common_definitions = json.load(f) | ||
| common_definitions = json.loads( |
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.
A more general question here: is there any advantage to storing the schema in JSON, rather than just inline in Python?
The way I had setup the spec folder with JSON was to then programmatically generate Python and JS code using those specs as a common base. If we don't need the schema in JS then just having it directly in Python might avoid these issues.
This also is not a blocker, as it's clearly following what we do for other constants (I just also have a general intention to migrate those to a more 'spec' style in future).
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 there any advantage to storing the schema in JSON, rather than just inline in Python?
Probably not. Might be good to do an audit to asses if the JS schemas are in use prior to the change which should be pretty straight forward, I think!
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.
Yeah - we don't need to make any changes here. I can write up a follow up issue for this broader question.
bjester
left a comment
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.
Existing tests seem sufficient, and discussion has resolved questions about implementation
Summary
This PR fixes an issue where the embed resolver was unable to locate a resource within the context of a python package. The fix involved moving the common embed definitions file to the resources folder and using
json.loadsin combination withpkgutil.get_data, aligning with how internal resources are accessed in other parts of the package.References
https://github.com/learningequality/studio/actions/runs/14479363608/job/40612747596?pr=5005
Reviewer guidance