[SYNPY-1726] Add bind-jsonschema CLI command#1317
[SYNPY-1726] Add bind-jsonschema CLI command#1317thomasyu888 merged 32 commits intoSage-Bionetworks:developfrom
Conversation
- Create schema_management.py with register_jsonschema and bind_jsonschema - Export functions from curator extension __init__.py
- Update register_json_schema to use register_jsonschema wrapper - Update bind_json_schema to use bind_jsonschema wrapper - Add register-json-schema CLI command with argparse configuration
- Add register-json-schema to table of contents - Add complete command documentation with usage and parameters - Document schema registration workflow
- Update tutorial to cover complete JSON Schema workflow - Add section 9: Register JSON Schema to Synapse - Add section 10: Bind JSON Schema to entities - Update tutorial script with register_jsonschema and bind_jsonschema examples - Update imports and line references
- Add test for argument parsing - Add test for --enable-derived-annotations flag - Add test for API call invocation
Update test to mock bind_jsonschema wrapper instead of asyncio.run, and verify correct arguments are passed to the wrapper function.
|
Thanks for doing this @aditigopalan ! Could you add an integration test as well as the unit testing you did? |
- Update register_jsonschema to log message and return only schema_uri - Update CLI function to match new signature - Update docstring and examples
- Update return type from str to JSONSchema - Update docstring and examples to show accessing json_schema.uri - Update tutorial script accordingly
Add comprehensive integration tests for register_jsonschema and bind_jsonschema wrapper functions. Tests cover: - Registering schemas with and without version - Binding schemas to folders - Enabling derived annotations - Complete register + bind workflow
linglp
left a comment
There was a problem hiding this comment.
Thanks for your hard work @aditigopalan ! I left some comments about documentation and code style changes.
| Arguments: | ||
| schema_path: Path to the JSON schema file to register | ||
| organization_name: Name of the organization to register the schema under | ||
| schema_name: The name of the JSON schema |
There was a problem hiding this comment.
Nit: Name of the JSON Schema
This is to be consistent with organization_name
There was a problem hiding this comment.
What do you mean by this?
There was a problem hiding this comment.
I just meant that you have:
organization_name: Name of the organization to register the schema under
And similarly, we can do:
schema_name: Name of the JSON schema
thomasyu888
left a comment
There was a problem hiding this comment.
Thanks for your contribution @aditigopalan !
@andrewelamb or @linglp once all the changes are made, can one of you make sure the all the tests contributed here runs, since contributions via forks don't have CI tests.
Thanks all!
|
@linglp @andrewelamb thank you both for reviewing! Please let me know if I understood the documentation changes correctly. Regarding the organizations section, I’m not entirely sure what would make sense to include in the documentation. Since new organizations can be created, I’m not sure what it means for the JSON schemas to be “consistent with organization name.” For example, for HTAN2Organization, we generate schemas like these: I’m also not sure what other DCCs are doing in this space, so I’ll defer to you both (and @thomasyu888) on what makes sense to describe in the documentation. |
|
@aditigopalan Thank you for adding the integration tests! However, they are not passing. These all need to be resolved: |
- previously tried to test if that the binding result contains entity information (like entityId or entity_id) - result is a JSONSchemaBinding object (a Python class instance), not a dictionary - just checking that the result is not none should be sufficient
Resolved conflicts in schema_operations documentation: - Kept display_label example from upstream - Added register_jsonschema and bind_jsonschema documentation - Updated line number references in markdown
| """Set up test state with organization and schema file""" | ||
| from synapseclient.models import SchemaOrganization | ||
|
|
||
| class SchemaState: |
There was a problem hiding this comment.
I'm confused by this class. Could you add documentation describing what it's for?
There was a problem hiding this comment.
This was originally just meant to be a container class to bundle everything, but on second thought I just decided to reuse test_state + separate fixtures for organization and schema_file. Let me know if this makes sense!
Now if cleanup fails, the test will fail
Add explicit schema unbinding before folder deletion to ensure schemas can be deleted (schemas cannot be deleted while bound - errors out)
- Remove SchemaState container class in favor of separate fixtures for schema_organization and schema_file. - aligns with the existing test pattern where test_state provides the core Synapse client, project, and parser, while additional fixtures provide test-specific resources.
BryanFauble
left a comment
There was a problem hiding this comment.
There are some items to fix, but this is great progress!
use class-scoped fixture, fix UUID naming, use addfinalizer
…ions - Add register_jsonschema_async and bind_jsonschema_async functions - Refactor sync functions to use wrap_async_to_sync pattern - Export async functions from curator __init__.py
|
Thanks for all the work @aditigopalan ! |
Problem:
The CLI didn't have a workflow for registering and binding JSON Schemas.
Specifically:
Highlighted in SYNPY-1762
Solution:
schema_management.pymodule that provides thin wrapper functions (register_jsonschema() and bind_jsonschema()), keeping CLI logic minimal and consistent with previous workregister-json-schemaCLI command that registers schemas using JSONSchema.store().bind-json-schemaCLI command that binds schemas to entities via Entity.bind_schema().Testing:
register-json-schemaandbind-json-schemaCLI commands.