From 727de66eee3f97ffddd61af664e2d300a058ec92 Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Tue, 2 Apr 2019 11:17:14 +0200 Subject: [PATCH] fixed assignment bug --- jupyter-openbis-extension/dataset.py | 16 ++-------------- jupyter-openbis-extension/sample.py | 4 +++- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/jupyter-openbis-extension/dataset.py b/jupyter-openbis-extension/dataset.py index 9a656c7..91c6a89 100644 --- a/jupyter-openbis-extension/dataset.py +++ b/jupyter-openbis-extension/dataset.py @@ -127,12 +127,13 @@ class DataSetUploadHandler(IPythonHandler): return errors = [] - print("--------------_HERE_-----------1") sample = None experiment = None if (data.get('entityIdentifier')): + sample = None + experiment = None try: sample = conn.openbis.get_sample(data.get('entityIdentifier')) except Exception as e: @@ -152,8 +153,6 @@ class DataSetUploadHandler(IPythonHandler): {"entityIdentifier": "please provide a sample or experiment identifier"} ) - print("--------------_HERE_-----------2") - parents = [] if data.get('parents'): parents = data.get('parents') @@ -165,8 +164,6 @@ class DataSetUploadHandler(IPythonHandler): "parent": "Parent DataSet not found: {}".format(parent) }) - print("--------------_HERE_-----------2a") - filenames = [] for filename in data.get('files'): filename = unquote(filename) @@ -176,7 +173,6 @@ class DataSetUploadHandler(IPythonHandler): errors.append({ "file": "File not found: {}".format(filename) }) - print("--------------_HERE_-----------3") try: dataset = conn.openbis.new_dataset( @@ -191,7 +187,6 @@ class DataSetUploadHandler(IPythonHandler): errors.append({ "create": 'Error while creating the dataset: {}'.format(e) }) - print("--------------_HERE_-----------4") # try to set the properties if data.get('props'): @@ -211,14 +206,12 @@ class DataSetUploadHandler(IPythonHandler): errors.append({ "prop."+prop_name : "is mandatory" }) - print("--------------_HERE_-----------5") # write errors back if already occured if errors: self.set_status(500) self.write({ "errors": errors }) return - print("--------------_HERE_-----------6") try: dataset.save() @@ -226,7 +219,6 @@ class DataSetUploadHandler(IPythonHandler): errors.append({ "save": 'Error while saving the dataset: {}'.format(e) }) - print("--------------_HERE_-----------7") # write errors back if they occured if errors: @@ -238,9 +230,7 @@ class DataSetUploadHandler(IPythonHandler): 'status': 200, 'statusText': 'Jupyter Notebook was successfully uploaded to: {} with permId: {}'.format(conn.name, dataset.permId) }) - print('Jupyter Notebook was successfully uploaded to: {} with permId: {}'.format(conn.name, dataset.permId)) - print("--------------_HERE_-----------8") def post(self, **params): """Handle a request to /openbis/dataset/connection_name/permId @@ -256,8 +246,6 @@ class DataSetUploadHandler(IPythonHandler): return data = self.get_json_body() - print("Received DATA") - print(data) self.upload_data(conn=conn,data=data) diff --git a/jupyter-openbis-extension/sample.py b/jupyter-openbis-extension/sample.py index 752dfe7..83f4a30 100644 --- a/jupyter-openbis-extension/sample.py +++ b/jupyter-openbis-extension/sample.py @@ -7,6 +7,8 @@ from urllib.parse import parse_qs def get_entity_for_identifier(conn, identifier): + + entity = None try: entity = conn.openbis.get_sample(identifier) except Exception as exc: @@ -17,9 +19,9 @@ def get_entity_for_identifier(conn, identifier): entity = conn.openbis.get_experiment(identifier) except Exception as exc: pass - return entity + def get_datasets(entity, start_with=None, count=None): datasets = entity.get_datasets(start_with=start_with, count=count) -- GitLab