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

Retain formatting of Display name for annotations and table column names #1330

Merged
merged 16 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions schematic/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@
"The component or data type from the data model which you can use to validate the "
"data filled in your manifest template."
),
"use_schema_label": (
"Store attributes using the schema label (--use_schema_label, default) or store attributes using the display label "
"(--use_display_label). Attribute display names in the schema must not only include characters that are "
"not accepted by Synapse. Annotation names may only contain: letters, numbers, '_' and '.'"
),
"hide_blanks": (
"This is a boolean flag. If flag is provided when command line utility is executed, annotations with blank values will be hidden from a dataset's annotation list in Synaspe."
"If not, annotations with blank values will be displayed."
Expand All @@ -127,7 +122,16 @@
"'upsert' should be used for initial table uploads if users intend to upsert into them at a later time."
"Using 'upsert' at creation will generate the metadata necessary for upsert functionality."
"Upsert functionality requires primary keys to be specified in the data model and manfiest as <component>_id."
"Currently it is required to use -dl/--use_display_label with table upserts."
"Currently it is required to use --table_column_names = display_name with table upserts."
),
"annotation_keys": (
"Store attributes using the class label (default) or store attributes using the display label. "
"Attribute display names in the schema must not only include characters that are "
"not accepted by Synapse. Annotation names may only contain: letters, numbers, '_' and '.'"
),
"table_column_names": (
"class_label, display_label, display_name, default, class_label. When true annotations and table columns will be uploaded with the display name formatting with blacklisted characters removed. "
"To use for tables, use in conjunction with the use_schema_label flag."
),
},
"validate": {
Expand Down
28 changes: 20 additions & 8 deletions schematic/models/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ def model(ctx, config): # use as `schematic model ...`
"--validate_component",
help=query_dict(model_commands, ("model", "submit", "validate_component")),
)
@click.option(
"--use_schema_label/--use_display_label",
"-sl/-dl",
default=True,
help=query_dict(model_commands, ("model", "submit", "use_schema_label")),
)
@click.option(
"--hide_blanks",
"-hb",
Expand Down Expand Up @@ -114,18 +108,35 @@ def model(ctx, config): # use as `schematic model ...`
type=click.Choice(["replace", "upsert"], case_sensitive=True),
help=query_dict(model_commands, ("model", "submit", "table_manipulation")),
)
@click.option(
"--table_column_names",
"-tcn",
default="class_label",
type=click.Choice(
["class_label", "display_label", "display_name"], case_sensitive=True
),
help=query_dict(model_commands, ("model", "submit", "table_column_names")),
)
@click.option(
"--annotation_keys",
"-ak",
default="class_label",
type=click.Choice(["class_label", "display_label"], case_sensitive=True),
help=query_dict(model_commands, ("model", "submit", "annotation_keys")),
)
@click.pass_obj
def submit_manifest(
ctx,
linglp marked this conversation as resolved.
Show resolved Hide resolved
manifest_path,
dataset_id,
validate_component,
manifest_record_type,
use_schema_label,
hide_blanks,
restrict_rules,
project_scope,
table_manipulation,
table_column_names,
annotation_keys,
):
"""
Running CLI with manifest validation (optional) and submission options.
Expand All @@ -145,10 +156,11 @@ def submit_manifest(
validate_component=validate_component,
manifest_record_type=manifest_record_type,
restrict_rules=restrict_rules,
use_schema_label=use_schema_label,
hide_blanks=hide_blanks,
project_scope=project_scope,
table_manipulation=table_manipulation,
table_column_names=table_column_names,
annotation_keys=annotation_keys,
)

if manifest_id:
Expand Down
17 changes: 11 additions & 6 deletions schematic/models/metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging
import networkx as nx
from os.path import exists
from jsonschema import ValidationError

# allows specifying explicit variable types
Expand All @@ -11,7 +12,6 @@
from schematic.schemas.data_model_parser import DataModelParser
from schematic.schemas.data_model_json_schema import DataModelJSONSchema


# TODO: This module should only be aware of the store interface
# we shouldn't need to expose Synapse functionality explicitly
from schematic.store.synapse import SynapseStorage
Expand Down Expand Up @@ -322,10 +322,11 @@ def submit_metadata_manifest(
restrict_rules: bool,
access_token: Optional[str] = None,
validate_component: Optional[str] = None,
use_schema_label: bool = True,
hide_blanks: bool = False,
project_scope: List = None,
table_manipulation: str = "replace",
table_column_names: str = "class_label",
annotation_keys: str = "class_label",
) -> str:
"""Wrap methods that are responsible for validation of manifests for a given component, and association of the
same manifest file with a specified dataset.
Expand Down Expand Up @@ -382,9 +383,10 @@ def submit_metadata_manifest(
metadataManifestPath=censored_manifest_path,
datasetId=dataset_id,
manifest_record_type=manifest_record_type,
useSchemaLabel=use_schema_label,
hideBlanks=hide_blanks,
table_manipulation=table_manipulation,
table_column_names=table_column_names,
annotation_keys=annotation_keys,
)
restrict_maniest = True

Expand All @@ -393,10 +395,11 @@ def submit_metadata_manifest(
metadataManifestPath=manifest_path,
datasetId=dataset_id,
manifest_record_type=manifest_record_type,
useSchemaLabel=use_schema_label,
hideBlanks=hide_blanks,
restrict_manifest=restrict_maniest,
table_manipulation=table_manipulation,
table_column_names=table_column_names,
annotation_keys=annotation_keys,
)

logger.info(f"No validation errors occured during validation.")
Expand All @@ -415,9 +418,10 @@ def submit_metadata_manifest(
metadataManifestPath=censored_manifest_path,
datasetId=dataset_id,
manifest_record_type=manifest_record_type,
useSchemaLabel=use_schema_label,
hideBlanks=hide_blanks,
table_manipulation=table_manipulation,
table_column_names=table_column_names,
annotation_keys=annotation_keys,
)
restrict_maniest = True

Expand All @@ -426,10 +430,11 @@ def submit_metadata_manifest(
metadataManifestPath=manifest_path,
datasetId=dataset_id,
manifest_record_type=manifest_record_type,
useSchemaLabel=use_schema_label,
hideBlanks=hide_blanks,
restrict_manifest=restrict_maniest,
table_manipulation=table_manipulation,
table_column_names=table_column_names,
annotation_keys=annotation_keys,
)

logger.debug(
Expand Down
Loading
Loading