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

Add an endpoint to dereference a schema #9

Merged
merged 6 commits into from
Oct 19, 2020

Conversation

aaclan-ebi
Copy link
Contributor

@aaclan-ebi aaclan-ebi commented Oct 14, 2020

@aaclan-ebi aaclan-ebi requested a review from a team October 15, 2020 10:21
@aaclan-ebi aaclan-ebi self-assigned this Oct 15, 2020
@aaclan-ebi aaclan-ebi requested review from rdgoite and prabh-t October 15, 2020 10:22
@aaclan-ebi aaclan-ebi marked this pull request as ready for review October 15, 2020 10:22
Copy link
Contributor

@rdgoite rdgoite left a comment

Choose a reason for hiding this comment

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

Approved with comments.

pandas~=1.1.1
PyYAML~=5.1
mock~=3.0.5
dataclasses~=0.6
argparse~=1.4.0

jsonref~=0.2
Copy link
Contributor

Choose a reason for hiding this comment

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

This project looks like it hasn't been touched in a good while, and it hasn't even reached a major release. This could cause issues in the future, so keep an eye on this.

def __init__(self):
self.json_loader = jsonref.JsonLoader()

def dereference_schema(self, json_schema):
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a good idea to annotate method declarations with types, like def dereference_schema(self, json_schema: dict) -> JsonRef or something.


def dereference_schema(self, json_schema):
json_ref_obj = jsonref.loads(json.dumps(json_schema), loader=self.json_loader)
return json_ref_obj
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not a good idea to return an object type from a third party library. Might be best to keep usage of jsonref internal so it's easy to replace it with something if ever.

@@ -178,8 +183,52 @@ def get_spreadsheet(job_id: str):
)


# http://0.0.0.0:5000/schemas?high_level_entity=type&domain_entity=biomaterial&concrete_entity=donor_organism&latest&json
# http://0.0.0.0:5000/schemas?url=${schemaUrl}&json&deref
@app.route('/schemas', methods=['GET'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we implementing this here and not in core where we have the schemas endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i'll probably remove the retrieving of latest schema here 🤔 i actually want to remove the schema endpoints from core, and have a separate schema service. Or i can just put the dereferencing in Core. Let me think about this a bit more...

Copy link
Contributor Author

@aaclan-ebi aaclan-ebi Oct 19, 2020

Choose a reason for hiding this comment

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

Unfortunately, given the time remaining for the sprint, i won't be able implement this in Core or separate schema service. I will keep take note of this for now. And track this in zenhub.

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 added this issue for now ebi-ait/hca-ebi-dev-team#345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants