Skip to content

[SYNPY-1777] Add fix_schema_name#1327

Merged
andrewelamb merged 9 commits intodevelopfrom
SYNPY-1777
Feb 25, 2026
Merged

[SYNPY-1777] Add fix_schema_name#1327
andrewelamb merged 9 commits intodevelopfrom
SYNPY-1777

Conversation

@andrewelamb
Copy link
Contributor

@andrewelamb andrewelamb commented Feb 24, 2026

Problem:

In Synapse Organizations, JSON Schema names aren't allowed to have dashes or underscores. AD/Elite schems use these as separators (ie. Cell-Line). Registering JSON Schemas needed a way to fix these.

Solution:

The register_json_schema function now has the fix_schema_name parameter that replaces dashes and underscores with periods. For example, Cell-Line -> Cell.Line
I also fixed the line numbers in the schema operations doc. They were all off by 10 lines.

Testing:

  • Unit tests for register_json_schema with and without using fix_schema_name
  • Integration test for register_json_schema CLI using fix_schema_name

@andrewelamb andrewelamb requested a review from a team as a code owner February 24, 2026 17:43
@andrewelamb andrewelamb marked this pull request as draft February 24, 2026 17:43
@andrewelamb andrewelamb marked this pull request as ready for review February 24, 2026 17:55
@thomasyu888 thomasyu888 requested a review from linglp February 25, 2026 00:03
Copy link
Member

@thomasyu888 thomasyu888 left a comment

Choose a reason for hiding this comment

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

🔥 LGTM! I'll defer to @linglp for final review

Copy link
Contributor

@linglp linglp left a comment

Choose a reason for hiding this comment

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

I think the PR is definitely 99% there. But here are some of my thoughts:

  • The documentation about calling registering JSON Schema would probably also need to be updated since this also added a parameter in the register JSON Schema function
  • I am curious why we don't set --fix-schema-name to True by default? Wouldn't this provide a better user experience since they would want their schema names to work?
  • Can we add some sort of validation after the dashes and underscores get replaced? Some edge cases that I listed in the comments are not likely to happen, but we might still want to add the check for completeness
  • When using the command line, I think maybe it will be better if we print out the logs when the fix happens. For example, schema name: "abc_def" now becomes "abc.def"

| `organization_name` | Positional | Name of the organization to register the schema under | |
| `schema_name` | Positional | The name of the JSON schema | |
| `--schema-version` | Named | Version of the schema to register (e.g., '0.0.1'). If not specified, auto-generated | None |
| `--fix-schema-name` | Named | Replace dashes and underscores in the schema name with periods. | False |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think in addition to updating the documentation here, this tutorial for registering JSON Schema would also need to be updated: https://synapsepythonclient--1327.org.readthedocs.build/en/1327/tutorials/python/schema_operations/?h=register+json+schema#8-register-a-json-schema-to-synapse

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think the help text can be more descriptive: help="Replaces dashes and underscores with periods in the schema name (e.g., 'my-schema_name' becomes 'my.schema.name')

from synapseclient import Synapse
from synapseclient.models.schema_organization import JSONSchema

if fix_schema_name:
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if this edge case also needs to be handled by this PR here, but what if the schema_name is something like "schema--abc__test" where there are multiple dashes? After transformation, the schema name will become: 'schema..abc..test' which is still invalid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also what if there are only dashes? "----" will become something like ".....". Do we need to handle cases like these as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we might need to add code to make sure that the name is actually valid?

@andrewelamb andrewelamb changed the title add fix_schema_name [SYNPY-1777] Add fix_schema_name Feb 25, 2026
@andrewelamb
Copy link
Contributor Author

I am curious why we don't set --fix-schema-name to True by default? Wouldn't this provide a better user experience since they would want their schema names to work?

We don't want to change their schema names without them being aware of the fact. They need to opt in to this change so-to-speak.

@andrewelamb andrewelamb requested a review from linglp February 25, 2026 17:12
Copy link
Contributor

@linglp linglp left a comment

Choose a reason for hiding this comment

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

LGTM! I tested the CLI command locally and it worked as expected. Another minor comment is about the documentation. If you don't mind, could you also fix the formatting of the documentation in the PR? I think the bullet points are not properly formatted: https://synapsepythonclient--1327.org.readthedocs.build/en/1327/tutorials/python/schema_operations/#8-register-a-json-schema-to-synapse

Image

@andrewelamb andrewelamb merged commit 486a9fc into develop Feb 25, 2026
4 of 5 checks passed
@andrewelamb andrewelamb deleted the SYNPY-1777 branch February 25, 2026 21:16

syn = Synapse.get_client(synapse_client=synapse_client)

if fix_schema_name:
Copy link
Contributor

Choose a reason for hiding this comment

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

@andrewelamb I just noticed there's a bug in the code. The log should only be printed if there's actually a name change. I am seeing such as below when there's no name changes:

Changed schema name from 'ComputationalToolsTemplate' to 'ComputationalToolsTemplate'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, that's when fix_schema_names is turned on, but no change actually gets made. That's a quick fix.

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.

3 participants