From a3d6d59297f818ceb12c09f9a86e29013a281f20 Mon Sep 17 00:00:00 2001 From: Christina Conrad <114612268+cconrad8@users.noreply.github.com> Date: Fri, 31 Jan 2025 13:59:59 -0500 Subject: [PATCH] Create bind_dataset_json.py --- example_script/bind_dataset_json.py | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 example_script/bind_dataset_json.py diff --git a/example_script/bind_dataset_json.py b/example_script/bind_dataset_json.py new file mode 100644 index 00000000..3cac146b --- /dev/null +++ b/example_script/bind_dataset_json.py @@ -0,0 +1,41 @@ +import synapseclient +import time +import json + +# Initialize Synapse client and login +def initialize_synapse(): + syn = synapseclient.Synapse() + syn.login() # Add your username and password if needed + return syn + +# Define the schema binding function +def bind_schema(syn, object_id, schema_id): + print(f"Binding schema '{schema_id}' to entity '{object_id}'...") + bind_request = { + "entityId": object_id, + "schema$id": schema_id + } + syn.restPUT(f"/entity/{object_id}/schema/binding", json.dumps(bind_request)) + print("Schema successfully bound to the entity.") + +# Main function to run the script +def main(): + syn = initialize_synapse() + + + # # Create schema + # job_status = create_schema(syn, schema_request_body) + + # Object IDs to bind schema to + object_ids = [ + "syn52369033" + ] # Replace with actual entity IDs + + schema_id = "https://repo-prod.prod.sagebase.org/repo/v1/schema/type/registered/org.synapse.nf-superdataset" + + # Bind each schema + for object_id in object_ids: + bind_schema(syn, object_id, schema_id) + +if __name__ == "__main__": + main()