diff options
| -rw-r--r-- | cli/app/commands/cortex/upload_video.py | 14 | ||||
| -rw-r--r-- | cli/app/utils/cortex_utils.py | 6 |
2 files changed, 15 insertions, 5 deletions
diff --git a/cli/app/commands/cortex/upload_video.py b/cli/app/commands/cortex/upload_video.py index 138bdf5..f8b9686 100644 --- a/cli/app/commands/cortex/upload_video.py +++ b/cli/app/commands/cortex/upload_video.py @@ -2,19 +2,22 @@ import click import json from app.search.video import export_video_final -from app.utils.cortex_utils import upload_file_to_cortex +from app.utils.cortex_utils import results_folder, upload_file_to_cortex @click.command('') @click.option('-i', '--input', 'opt_fp_in', - help='Path to input image') -@click.option('-f', '--folder_id', 'opt_folder_id', required=True, - help='ID of folder on Cortex') + help='Path to input folder (default: most recent folder in results)') +@click.option('-f', '--folder_id', 'opt_folder_id', + help='ID of folder on Cortex (default: results folder)') @click.pass_context def cli(ctx, opt_fp_in, opt_folder_id): """ Test uploading a file to Cortex """ - # export_video_final + if opt_folder_id is None: + folder = results_folder() + opt_folder_id = folder['id'] + if opt_fp_in is None: results_dir = os.path.join(app_cfg.RESULTS_DIR) for fn in sorted(os.listdir(app_cfg.RESULTS_DIR), reverse=True): @@ -28,6 +31,7 @@ def cli(ctx, opt_fp_in, opt_folder_id): if not os.path.exists(fp_out): print("No video found") return + print("Uploading {}".format(fp_out)) data = upload_file_to_cortex(opt_folder_id, fp_out, datatype='video', activity='live') print(json.dumps(data, indent=2)) diff --git a/cli/app/utils/cortex_utils.py b/cli/app/utils/cortex_utils.py index bf49f96..0de9596 100644 --- a/cli/app/utils/cortex_utils.py +++ b/cli/app/utils/cortex_utils.py @@ -13,6 +13,12 @@ def api_url(path): def cortex_folder(opt_folder_id): return fetch_json(os.path.join(api_url('folder'), str(opt_folder_id) + "/")) +def results_folder(name="results", module="biggan"): + res = fetch_json(api_url('folder'), name=name, module=module) + if len(res): + return res[0] + raise Exception("No results folder!") + def download_cortex_files(opt_folder_id): """Fetch all new, non-generated files in a Cortex folder""" rows = fetch_json(api_url('file'), folder_id=opt_folder_id) |
