about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--scripts/load_phenotypes_to_db.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/scripts/load_phenotypes_to_db.py b/scripts/load_phenotypes_to_db.py
index 223a435..dc083cd 100644
--- a/scripts/load_phenotypes_to_db.py
+++ b/scripts/load_phenotypes_to_db.py
@@ -318,7 +318,26 @@ def update_auth(authserver, token, species, population, dataset, xrefdata):
                 "data_link_ids": [
                     item["data_link_id"] for item in linkeddata["traits"]]
             }).then(lambda attc: (user, linkeddata, resource, attc))
-    raise NotImplementedError("Please implement this!")
+
+    def __handle_error__(resp):
+        logger.error("ERROR: Updating the authorisation for the data failed.")
+        logger.debug(
+            "ERROR: The response from the authorisation server was:\n\t%s",
+            resp.json())
+        return 1
+
+    def __handle_success__(val):
+        logger.info(
+            "The authorisation for the data has been updated successfully.")
+        return 0
+
+    return __fetch_user_details__().then(__link_data__).then(
+        lambda result: __fetch_phenotype_category_details__(*result)
+    ).then(
+        lambda result: __create_resource__(*result)
+    ).then(
+        lambda result: __attach_data_to_resource__(*result)
+    ).either(__handle_error__, __handle_success__)
 
 
 def load_data(conn: mysqldb.Connection, job: dict) -> int: