From 1e57e33c833679746ac372d8934e418f76bcf289 Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Mon, 6 Nov 2023 17:15:56 -0600 Subject: [PATCH] update sciviz --- aeon/dj_pipeline/populate/worker.py | 2 +- aeon/dj_pipeline/subject.py | 5 ++- .../dj_pipeline/webapps/sciviz/specsheet.yaml | 45 ++++++++++++------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/aeon/dj_pipeline/populate/worker.py b/aeon/dj_pipeline/populate/worker.py index 75b8b131..25b910d1 100644 --- a/aeon/dj_pipeline/populate/worker.py +++ b/aeon/dj_pipeline/populate/worker.py @@ -101,7 +101,7 @@ def ingest_environment_visits(): worker_schema_name=worker_schema_name, db_prefix=db_prefix, run_duration=-1, - sleep_duration=1200, + sleep_duration=10, ) pyrat_worker(subject.CreatePyratIngestionTask) diff --git a/aeon/dj_pipeline/subject.py b/aeon/dj_pipeline/subject.py index 52c13016..4a049a4f 100644 --- a/aeon/dj_pipeline/subject.py +++ b/aeon/dj_pipeline/subject.py @@ -433,6 +433,7 @@ def make(self, key): "import_order_request_id", ] + def get_pyrat_data(endpoint: str, params: dict = None, **kwargs): base_url = "https://swc.pyrat.cloud/api/v3/" pyrat_system_token = os.getenv("PYRAT_SYSTEM_TOKEN") @@ -461,6 +462,8 @@ def get_pyrat_data(endpoint: str, params: dict = None, **kwargs): response = session.get(base_url + endpoint + params_str, **kwargs) if response.status_code != 200: - raise requests.exceptions.HTTPError(f'PyRat API errored out with response code: {response.status_code}') + raise requests.exceptions.HTTPError( + f"PyRat API errored out with response code: {response.status_code}" + ) return response.json() diff --git a/aeon/dj_pipeline/webapps/sciviz/specsheet.yaml b/aeon/dj_pipeline/webapps/sciviz/specsheet.yaml index 58bbbea7..841f8069 100644 --- a/aeon/dj_pipeline/webapps/sciviz/specsheet.yaml +++ b/aeon/dj_pipeline/webapps/sciviz/specsheet.yaml @@ -46,10 +46,25 @@ SciViz: columns: 1 row_height: 1000 components: + Pyrat Subjects: + route: /colony_page_pyrat_subjects + x: 0 + y: 0 + height: 0.6 + width: 1 + type: antd-table + restriction: > + def restriction(**kwargs): + return dict(**kwargs) + dj_query: > + def dj_query(aeon_subject): + query = aeon_subject.Subject * aeon_subject.SubjectDetail * aeon_subject.SubjectReferenceWeight.proj('reference_weight', min_since_last_update='TIMESTAMPDIFF(MINUTE, last_updated_time, UTC_TIMESTAMP())') & 'available = 1' + return {'query': query.proj(..., '-available'), 'fetch_args': []} + Pyrat User Entry: route: /colony_page_pyrat_user_entry x: 0 - y: 0 + y: 0.6 height: 0.3 width: 1 type: form @@ -65,20 +80,20 @@ SciViz: - type: attribute input: Pyrat Responsible ID destination: responsible_id - Pyrat Subjects: - route: /colony_page_pyrat_subjects - x: 0 - y: 0.3 - height: 0.6 - width: 1 - type: antd-table - restriction: > - def restriction(**kwargs): - return dict(**kwargs) - dj_query: > - def dj_query(aeon_subject): - query = aeon_subject.Subject * aeon_subject.SubjectDetail * aeon_subject.SubjectReferenceWeight.proj('reference_weight', min_since_last_update='TIMESTAMPDIFF(MINUTE, last_updated_time, UTC_TIMESTAMP())') & 'available = 1' - return {'query': query, 'fetch_args': []} + + Pyrat Sync Task: + route: /colony_page_pyrat_sync_task + x: 0 + y: 0.9 + height: 0.3 + width: 1 + type: form + tables: + - aeon_subject.PyratIngestionTask + map: + - type: attribute + input: Task Scheduled Time + destination: pyrat_task_scheduled_time ExperimentEntry: route: /experiment_entry