Skip to content

Conversation

@linglp
Copy link
Contributor

@linglp linglp commented Nov 7, 2025

Problem:

  • There are two ways to define a JSON Schema type: explicitly through columnType, or implicitly through a validation rule. This PR deprecates setting the JSON Schema type via validation rules.
  • Tests related to JSON Schema creation have not yet been migrated from the schematic repository.
  • The current implementation of create_json_schema is missing some parameters compared to the version in schematic. See reference: schematic/schemas/create_json_schema.py#L543
  • The _write_data_model function is missing. See reference: schematic/schemas/create_json_schema.py#L658
  • Some useful helper functions in schematic’s conftest.py are also missing.

Solution:

  • Move the following over to the Python client:
  1. _write_data_model: https://github.com/Sage-Bionetworks/schematic/blob/develop/schematic/schemas/create_json_schema.py#L658
  2. Moved a mini version of conftest from schematic: https://github.com/Sage-Bionetworks/schematic/blob/develop/tests/conftest.py.
  3. Moved a mini version of MetadataModel
  4. Fixed missing parameters in create_json_schema
  5. Moved the whole unit test over: test_create_json_schema.py
  6. Addressed hard-coded paths in the original unit tests and reorganized test files under the new schema_files directory

The following functions are now removed:

  • get_js_type_from_inputted_rules

The following functions will be deprecated:

  • filter_unused_inputted_rules
  • check_for_duplicate_inputted_rules
  • check_for_conflicting_inputted_rules
  • get_validation_rule_names_from_inputted_rules
  • get_names_from_inputted_rules

Testing:

return model_dataframe


class MetadataModel(object):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a pared-down version of schematic’s MetadataModel. It omits legacy features—such as manifest validation and submission—that we no longer need. See the original MetadataModel for reference: https://github.com/Sage-Bionetworks/schematic/blob/develop/schematic/models/metadata.py#L28


def __init__(
self,
inputMModelLocation: str,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not up to the variable standard of the synapse python client. I will either adjust it in this PR or create a new ticket.

@linglp linglp changed the title [SYNPY-1681] Set json schema type based on ColumnType; abolish setting json schema type via validation rule [SYNPY-1681] Set JSON Schema type based on columnType; remove type setting via validation rules Nov 7, 2025
${{ steps.get-dependencies.outputs.site_packages_loc }}
${{ steps.get-dependencies.outputs.site_bin_dir }}
key: ${{ runner.os }}-${{ matrix.python }}-build-${{ env.cache-name }}-${{ hashFiles('setup.py') }}-v28
key: ${{ runner.os }}-${{ matrix.python }}-build-${{ env.cache-name }}-${{ hashFiles('setup.py', 'setup.cfg') }}-v28
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sure that CI/CD reinstall dependencies if setup.cfg changes.

return json_schema_dict


def _write_data_model(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

May raise errors if the component is not found in the data model graph.
"""

metadata_model = MetadataModel(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

datatype=self.component,
logger=self.logger,
schema_name=self.component + "_validation",
jsonld_path=metadata_model.inputMModelLocation,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

)

TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
SCHEMA_FILES_DIR = os.path.join(TESTS_DIR, "schema_files")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no more data directory. I organized everything under the new schema_files directory

TEST_DISPLAY_NAMES_SCHEMA_PATTERN = "test.{datatype}.display_names_schema.json"


# Helper functions for path construction
Copy link
Contributor Author

@linglp linglp Nov 7, 2025

Choose a reason for hiding this comment

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

The original schematic has file paths hard-coded all over all the place in the test. Please see below as some examples:

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.

I know this is draft mode, but you may want to consider letting the team know to work off of this branch when ready as there are some big changes here that may or may not impact people's development of curator extension.

INT = "int"
BOOL = "bool"
NUM = "num"

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the type validation rules here

@linglp linglp marked this pull request as ready for review November 10, 2025 21:18
@linglp linglp requested a review from a team as a code owner November 10, 2025 21:18
@andrewelamb
Copy link
Contributor

Thanks @linglp ! LGTM

@andrewelamb
Copy link
Contributor

@linglp gentle reminder: create the tickets for todos you mentioned in the comments, and for other missing tests you found in this epic.

${{ steps.get-dependencies.outputs.site_packages_loc }}
${{ steps.get-dependencies.outputs.site_bin_dir }}
key: ${{ runner.os }}-${{ matrix.python }}-build-${{ env.cache-name }}-${{ hashFiles('setup.py') }}-v28
key: ${{ runner.os }}-${{ matrix.python }}-build-${{ env.cache-name }}-${{ hashFiles('setup.py') }}-v29
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See PR here: https://github.com/Sage-Bionetworks/synapsePythonClient/pull/1266/files#diff-5c3fa597431eda03ac3339ae6bf7f05e1a50d6fc7333679ec38e21b337cb6721

I updated it to v29 to ensure dependencies can be updated when running github actions.

@linglp linglp merged commit d3256f6 into develop Nov 11, 2025
15 of 21 checks passed
@linglp linglp deleted the synpy-1681 branch November 11, 2025 17:51
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.

4 participants