Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widefield #70

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions deploy/serverpc/crontab/large_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time
import logging
from pathlib import Path
import multiprocessing

from one.api import ONE
from ibllib.pipes.local_server import task_queue
Expand All @@ -11,21 +12,28 @@
subjects_path = Path('/mnt/s0/Data/Subjects/')
sleep_time = 3600

try:
one = ONE(cache_rest=None)
waiting_tasks = task_queue(mode='large', lab=None, alyx=one.alyx)

if len(waiting_tasks) == 0:
_logger.info(f'No large tasks in the queue, retrying in {int(sleep_time / 60)} min')
# Query again only in 60min if queue is empty
time.sleep(sleep_time)
else:
tdict = waiting_tasks[0]
_logger.info(f"Running task {tdict['name']} for session {tdict['session']}")
ses = one.alyx.rest('sessions', 'list', django=f"pk,{tdict['session']}")[0]
session_path = Path(subjects_path).joinpath(
Path(ses['subject'], ses['start_time'][:10], str(ses['number']).zfill(3)))
run_alyx_task(tdict=tdict, session_path=session_path, one=one)
except Exception:
_logger.error(f'Error running large task queue \n {traceback.format_exc()}')
time.sleep(int(sleep_time / 2))
def run_large():
try:
one = ONE(cache_rest=None)
waiting_tasks = task_queue(mode='large', lab=None, alyx=one.alyx)

if len(waiting_tasks) == 0:
_logger.info(f"No large tasks in the queue, retrying in {int(sleep_time / 60)} min")
# Query again only in 60min if queue is empty
time.sleep(sleep_time)
else:
tdict = waiting_tasks[0]
_logger.info(f"Running task {tdict['name']} for session {tdict['session']}")
ses = one.alyx.rest('sessions', 'list', django=f"pk,{tdict['session']}")[0]
session_path = Path(subjects_path).joinpath(
Path(ses['subject'], ses['start_time'][:10], str(ses['number']).zfill(3)))
run_alyx_task(tdict=tdict, session_path=session_path, one=one)
except BaseException:
_logger.error(f"Error running large task queue \n {traceback.format_exc()}")
time.sleep(int(sleep_time / 2))


if __name__ == '__main__':
multiprocessing.freeze_support()
run_large()