From 0d62da83bd54af33545712c88da68c023b780752 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 24 Mar 2025 16:29:04 -0500 Subject: Begin processing the uploadeded bulk-edit file. --- uploader/phenotypes/views.py | 63 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'uploader') diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py index a50a8e7..00da78b 100644 --- a/uploader/phenotypes/views.py +++ b/uploader/phenotypes/views.py @@ -958,4 +958,65 @@ def edit_upload_phenotype_data(# pylint: disable=[unused-argument] dataset=dataset, activelink="edit-phenotype") - return "NOT Implemented: Would do actual edit." + edit_file = save_file(request.files["file-upload-bulk-edit-upload"], + Path(app.config["UPLOAD_FOLDER"])) + + from gn_libs import jobs as gnlibs_jobs + from gn_libs import sqlite3 + jobs_db = app.config["ASYNCHRONOUS_JOBS_SQLITE_DB"] + with sqlite3.connection(jobs_db) as conn: + job_id = uuid.uuid4() + _job = gnlibs_jobs.launch_job( + gnlibs_jobs.initialise_job(conn, + job_id, + [ + sys.executable, + "-m", + "scripts.phenotypes_bulk_edit", + jobs_db, + str(job_id) + ], + "phenotype-bulk-edit", + extra_meta = { + "edit-file": str(edit_file) + }), + jobs_db, + f"{app.config['UPLOAD_FOLDER']}/job_errors", + worker_manager="gn_libs.scripts.worker") + + + return """ +

The following steps need to be performed: +

    +
  1. Check that all IDs exist
  2. +
  3. Check for mandatory values
  4. +
  5. Update descriptions in the database (where changed)
  6. +
  7. Update publications in the database (where changed): +
      +
    1. If PubMed_ID exists in our database, simply update the + 'PublicationId' value in the 'PublishXRef' table.
    2. +
    3. If PubMed_ID does not exists in our database: +
        +
      1. fetch the publication's details from PubMed using the new + PubMed_ID value.
      2. +
      3. create a new publication in our database using the fetched data
      4. +
      5. Update 'PublicationId' value in 'PublishXRef' with ID of newly created + publication
      6. +
      +
    +
  8. +
  9. Update values in the database (where changed)
  10. +
+

+ +

Note: +

+

+ """ -- cgit v1.2.3