Skip to content

Commit

Permalink
Merge pull request #277 from ttngu207/datajoint_pipeline_pyrat
Browse files Browse the repository at this point in the history
update sciviz
  • Loading branch information
JaerongA authored Nov 6, 2023
2 parents 58a8de1 + a2dea93 commit f35b95c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion aeon/dj_pipeline/populate/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion aeon/dj_pipeline/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
45 changes: 30 additions & 15 deletions aeon/dj_pipeline/webapps/sciviz/specsheet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f35b95c

Please sign in to comment.