Skip to content

Commit

Permalink
Merge b20beb8 into 23d9e2a
Browse files Browse the repository at this point in the history
  • Loading branch information
ngreenwald committed Jun 9, 2020
2 parents 23d9e2a + b20beb8 commit 8954a8e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion caliban_toolbox/figure_eight_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import zipfile
import pandas as pd
import urllib
import json
import re

from getpass import getpass
Expand Down Expand Up @@ -129,6 +130,22 @@ def copy_job(job_id, key):
return new_job_id


def rename_job(job_id, key, name):
"""Helper function to create a Figure 8 job based on existing job.
Args:
job_id: ID number of job to rename
key: API key to access Figure 8 account
name: new name for job
"""

payload = {
'key': key,
'job': {'title': name}}

response = requests.put(
'https://api.appen.com/v1/jobs/{}.json'.format(job_id), jason=payload)


def upload_log_file(log_file, job_id, key):
"""Upload log file to populate a job for Figure8
Expand Down Expand Up @@ -156,14 +173,15 @@ def upload_log_file(log_file, job_id, key):
print("Data successfully uploaded to Figure Eight.")


def create_figure_eight_job(base_dir, job_id_to_copy, aws_folder, stage,
def create_figure_eight_job(base_dir, job_id_to_copy, job_name, aws_folder, stage,
rgb_mode=False, label_only=False, pixel_only=False):
"""Create a Figure 8 job and upload data to it. New job ID printed out for convenience.
Args:
base_dir: full path to job directory
job_id_to_copy: ID number of Figure 8 job to use as template for new job
aws_folder: folder in aws bucket where files be stored
job_name: name for new job
stage: specifies stage in pipeline for jobs requiring multiple rounds of annotation
pixel_only: flag specifying whether annotators will be restricted to pixel edit mode
label_only: flag specifying whether annotators will be restricted to label edit mode
Expand Down Expand Up @@ -194,6 +212,9 @@ def create_figure_eight_job(base_dir, job_id_to_copy, aws_folder, stage,
return
print('New job ID is: ' + str(new_job_id))

# set name of new job
rename_job(new_job_id, key, job_name)

# get relevant paths
npz_paths, npz_keys, url_paths, npzs = create_job_urls(crop_dir=upload_folder,
aws_folder=aws_folder,
Expand Down

0 comments on commit 8954a8e

Please sign in to comment.