Created
June 22, 2020 18:26
-
-
Save armenzg/1e61cec4b07f0dc50eaf1db2e49dda40 to your computer and use it in GitHub Desktop.
Code to create a task from another one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have tried to use create_task_from_def, however, the create.py module | |
# use of sessions is optimized to work within the context of a task | |
def create_task_from_definition(task, task_group_id): | |
'''This is a helper function to call create_task_from_def''' | |
root_url = get_root_url(os.environ.get('TASKCLUSTER_PROXY_URL', False)) | |
queue = Queue({ | |
'rootUrl': root_url, | |
'credentials': optionsFromEnvironment().get('credentials', {}), | |
}) | |
# Refresh timestamps | |
task['created'] = {'relative-datestamp': '0 hours'} | |
task['deadline'] = {'relative-datestamp': '24 hours'} | |
task['expires'] = {'relative-datestamp': '14 days'} | |
task = resolve_timestamps(current_json_time(datetime_format=True), task) | |
new_id = slugid.nice() | |
task['taskGroupId'] = task_group_id | |
import pdb; pdb.set_trace() | |
queue.createTask(new_id, task) | |
logger.info('Scheduled task: {}/tasks/{}'.format(root_url, new_id)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment