def get_task(username, m_wf_id, wf_id, task_id): """ Returns task identified by m_wf_id, wf_id, task_id. :query boolean pretty-print: Return formatted JSON response :statuscode 200: OK :statuscode 401: Authentication failure :statuscode 403: Authorization failure :statuscode 404: Not found :return type: Record :return resource: Task """ queries = StampedeWorkflowQueries(g.stampede_db_url) record = queries.get_task(task_id) # # Generate JSON Response # response_json = jsonify(record) return make_response(response_json, 200, JSON_HEADER)
def get_task(username, m_wf_id, wf_id, task_id): """ Returns task identified by m_wf_id, wf_id, task_id. :query boolean pretty-print: Return formatted JSON response :statuscode 200: OK :statuscode 401: Authentication failure :statuscode 403: Authorization failure :statuscode 404: Not found :return type: Record :return resource: Task """ queries = StampedeWorkflowQueries(g.stampede_db_url) record = queries.get_task(task_id) # # Generate JSON Response # response_json = jsonify(record) return make_response(response_json, 200, JSON_HEADER)
def file_metadata(file_name=None, list_files=False, trace=False, submit_dir=".", *args, **kwargs): logging.debug("task_metadata") if trace and not file_name: logging.error("file_name is required when trace is True") sys.exit(1) if not file_name: list_files = True logging.info( "file_name not provided, will list metadata for all files") try: root_wf_uuid, wf_uuid = get_workflow_uuid(submit_dir) logging.debug("Workflow UUID: %s" % wf_uuid) db_uri = get_workflow_uri(submit_dir) queries = StampedeWorkflowQueries(db_uri) if list_files: logging.debug("Get file metadata for all files") workflow_files = queries.get_workflow_files(wf_uuid) if workflow_files.total_filtered == 0: print("No files found") else: logging.debug("Get file metadata for lfn %r" % file_name) workflow_files = queries.get_workflow_files(wf_uuid, query="l.lfn == %r" % file_name) if workflow_files.total_filtered == 0: raise ValueError("Invalid file %r" % file_name) if trace: wf_file = workflow_files.records.values()[0] wf_id = wf_file.extras.wf_id task_id = wf_file.extras.task_id # Get workflow information root_wf = None wf = queries.get_workflow(wf_id) # If workflow is hierarchical workflow, get root workflow information if wf_id != wf.root_wf_id: root_wf = queries.get_workflow(wf.root_wf_id) if root_wf: root_wf_metas = queries.get_workflow_meta( root_wf.wf_id).records print("Root Workflow %s" % root_wf.wf_uuid) render_metas(root_wf_metas, " ") print() wf_metas = queries.get_workflow_meta(wf_id).records print("Workflow %s" % wf.wf_uuid) render_metas(wf_metas, " ") print() task = queries.get_task(task_id) task_metas = queries.get_task_meta(task_id).records print("Task %s" % task.abs_task_id) render_metas(task_metas, " ") print() for wf_file in workflow_files.records: print("File %s" % wf_file.lfn) render_metas(wf_file.meta, " ") except ValueError as e: logging.error(e) sys.exit(1) except ConnectionError as e: logging.error(e) sys.exit(2) except StampedeDBNotFoundError as e: logging.error(e) sys.exit(3)
def file_metadata(file_name=None, list_files=False, trace=False, submit_dir='.', *args, **kwargs): logging.debug('task_metadata') if trace and not file_name: logging.error('file_name is required when trace is True') sys.exit(1) if not file_name: list_files = True logging.info( 'file_name not provided, will list metadata for all files') try: root_wf_uuid, wf_uuid = get_workflow_uuid(submit_dir) logging.debug('Workflow UUID: %s' % wf_uuid) db_uri = get_workflow_uri(submit_dir) queries = StampedeWorkflowQueries(db_uri) if list_files: logging.debug('Get file metadata for all files') workflow_files = queries.get_workflow_files(wf_uuid) if workflow_files.total_filtered == 0: print 'No files found' else: logging.debug('Get file metadata for lfn %r' % file_name) workflow_files = queries.get_workflow_files(wf_uuid, query='l.lfn = %r' % file_name) if workflow_files.total_filtered == 0: raise ValueError('Invalid file %r' % file_name) if trace: wf_file = workflow_files.records.values()[0] wf_id = wf_file.extras.wf_id task_id = wf_file.extras.task_id # Get workflow information root_wf = None wf = queries.get_workflow(wf_id) # If workflow is hierarchical workflow, get root workflow information if wf_id != wf.root_wf_id: root_wf = queries.get_workflow(wf.root_wf_id) if root_wf: root_wf_metas = queries.get_workflow_meta( root_wf.wf_id).records print 'Root Workflow %s' % root_wf.wf_uuid render_metas(root_wf_metas, ' ') print wf_metas = queries.get_workflow_meta(wf_id).records print 'Workflow %s' % wf.wf_uuid render_metas(wf_metas, ' ') print task = queries.get_task(task_id) task_metas = queries.get_task_meta(task_id).records print 'Task %s' % task.abs_task_id render_metas(task_metas, ' ') print for wf_file in workflow_files.records: print 'File %s' % wf_file.lfn render_metas(wf_file.meta, ' ') except ValueError as e: logging.error(e) sys.exit(1) except ConnectionError as e: logging.error(e) sys.exit(2) except StampedeDBNotFoundError as e: logging.error(e) sys.exit(3)