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

If dataset is protected make revision #19

Open
wants to merge 2 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
15 changes: 13 additions & 2 deletions iblvideo/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import traceback
import shutil
import requests

from glob import glob
from datetime import datetime
Expand Down Expand Up @@ -62,8 +63,18 @@ def run_session(session_id, machine=None, cams=None, one=None, remove_videos=Tru
# it is safer to instantiate the FTP right before transfer to prevent time-out
ftp_patcher = FTPPatcher(one=one)
if len(task.outputs) > 0:
for output in task.outputs:
ftp_patcher.create_dataset(path=output)
try:
for output in task.outputs:
ftp_patcher.create_dataset(path=output)
except requests.HTTPError:
revision = datetime.today().strftime("%Y-%m-%d")
_logger.warning(f'Creating revision {revision}')
revision_path = session_path.joinpath('alf', f'#{revision}#')
revision_path.mkdir()
for output in task.outputs:
new_output = revision_path.joinpath(output.name)
shutil.move(output, new_output)
ftp_patcher.create_dataset(path=new_output)
# Update the version only now and only if new outputs are uploaded
one.alyx.rest('tasks', 'partial_update', id=tdict['id'], data={'version': task.version})
else:
Expand Down