Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Keyword arguments:
file_type -- limit search to a file type, i.e. FileFastq (default=File)
start_date -- limit search to files generated since date YYYY-MM-DD
run_time -- assume runs beyond run_time are dead (default=24 hours)
"""
start = datetime.utcnow()
check = CheckResult(connection, 'md5runCGAP_status')
my_auth = connection.ff_keys
check.action = "md5runCGAP_start"
check.brief_output = []
check.full_output = {}
check.status = 'PASS'
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
# Build the query
query = '/search/?status=uploading&status=upload failed'
# add file type
f_type = kwargs.get('file_type')
query += '&type=' + f_type
# add date
s_date = kwargs.get('start_date')
if s_date:
query += '&date_created.from=' + s_date
def check_indexing(check, connection):
"""Checks the indexing queue, if there are items in the queue,
Modifies the check, and returns it along with a flag that is set to True,
if no items, returns original checks, and flag False"""
# wait for random time
wait = round(random.uniform(0.1, random_wait), 1)
time.sleep(wait)
# # TEMPORARILY DISABLE ALL PIPELINE RUNS
# check.status = 'PASS' # maybe use warn?
# check.brief_output = ['Check Temporarily Disabled']
# check.summary = 'Check Temporarily Disabled'
# check.full_output = {}
# return check, True
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check, True
else:
return check, False
check = CheckResult(connection, 'margi_status')
my_auth = connection.ff_keys
check.action = "margi_start"
check.brief_output = []
check.summary = ""
check.description = "run missing steps and add processing results to processed files, match set status"
check.full_output = {'skipped': [], 'running_runs': [], 'needs_runs': [],
'completed_runs': [], 'problematic_runs': []}
check.status = 'PASS'
exp_type = 'MARGI'
# completion tag
tag = wfr_utils.accepted_versions[exp_type][-1]
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
# Build the query, add date and lab if available
query = wfr_utils.build_exp_type_query(exp_type, kwargs)
# The search
res = ff_utils.search_metadata(query, key=my_auth)
print(len(res))
if not res:
check.summary = 'All Good!'
return check
check = CheckResult(connection, 'in_situ_hic_status')
my_auth = connection.ff_keys
check.action = "in_situ_hic_start"
check.description = "run missing steps and add processing results to processed files, match set status"
check.brief_output = []
check.summary = ""
check.full_output = {'skipped': [], 'running_runs': [], 'needs_runs': [],
'completed_runs': [], 'problematic_runs': []}
check.status = 'PASS'
exp_type = 'in situ Hi-C'
# completion tag
tag = wfr_utils.accepted_versions[exp_type][-1]
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
# Build the query, add date and lab if available
query = wfr_utils.build_exp_type_query(exp_type, kwargs)
# The search
res = ff_utils.search_metadata(query, key=my_auth)
if not res:
check.summary = 'All Good!'
return check
check = wfr_utils.check_hic(res, my_auth, tag, check, start, lambda_limit)
def md5run_status_extra_file(connection, **kwargs):
"""Searches for extra files that are uploaded to s3, but not went though md5 run.
no action is associated, we don't have any case so far.
Will be implemented if this check gets WARN"""
check = CheckResult(connection, 'md5run_status_extra_file')
my_auth = connection.ff_keys
check.status = 'PASS'
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
# Build the query
query = ('/search/?type=File&status!=uploading&status!=upload failed&status!=to be uploaded by workflow'
'&extra_files.status!=uploaded&extra_files.href!=No value')
# The search
res = ff_utils.search_metadata(query, key=my_auth)
if not res:
check.summary = 'All Good!'
return check
else:
"""
start = datetime.utcnow()
check = CheckResult(connection, 'repli_2_stage_status')
my_auth = connection.ff_keys
check.action = "repli_2_stage_start"
check.description = "run missing steps and add processing results to processed files, match set status"
check.brief_output = []
check.full_output = {'skipped': [], 'running_runs': [], 'needs_runs': [],
'completed_runs': [], 'problematic_runs': []}
check.status = 'PASS'
exp_type = '2-stage Repli-seq'
tag = wfr_utils.accepted_versions[exp_type][-1]
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
# Build the query, add date and lab if available
query = wfr_utils.build_exp_type_query(exp_type, kwargs)
# The search
res = ff_utils.search_metadata(query, key=my_auth)
if not res:
check.summary = 'All Good!'
return check
check = wfr_utils.check_repli(res, my_auth, tag, check, start, lambda_limit)
return check
"""
start = datetime.utcnow()
check = CheckResult(connection, 'nad_seq_status')
my_auth = connection.ff_keys
check.action = "nad_seq_start"
check.description = "run missing steps and add processing results to processed files, match set status"
check.brief_output = []
check.full_output = {'skipped': [], 'running_runs': [], 'needs_runs': [],
'completed_runs': [], 'problematic_runs': []}
check.status = 'PASS'
exp_type = 'NAD-seq'
tag = wfr_utils.accepted_versions[exp_type][-1]
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
# Build the query, add date and lab if available
query = wfr_utils.build_exp_type_query(exp_type, kwargs)
# The search
res = ff_utils.search_metadata(query, key=my_auth)
if not res:
check.summary = 'All Good!'
return check
check = wfr_utils.check_repli(res, my_auth, tag, check, start, lambda_limit)
return check
run_time -- assume runs beyond run_time are dead
"""
start = datetime.utcnow()
check = CheckResult(connection, 'cram_status')
my_auth = connection.ff_keys
check.action = "cram_start"
check.description = "run missing steps and add processing results to processed files, match set status"
check.brief_output = []
check.summary = ""
check.full_output = {'skipped': [], 'running_runs': [], 'needs_runs': [],
'completed_runs': [], 'problematic_runs': []}
check.status = 'PASS'
# check indexing queue
env = connection.ff_env
indexing_queue = ff_utils.stuff_in_queues(env, check_secondary=True)
if indexing_queue:
check.status = 'PASS' # maybe use warn?
check.brief_output = ['Waiting for indexing queue to clear']
check.summary = 'Waiting for indexing queue to clear'
check.full_output = {}
return check
q = '/search/?type=Sample&files.display_title=No+value&cram_files.display_title%21=No+value'
all_samples = ff_utils.search_metadata(q, my_auth)
print(len(all_samples))
for a_sample in all_samples:
all_items, all_uuids = ff_utils.expand_es_metadata([a_sample['uuid']], my_auth,
store_frame='embedded',
add_pc_wfr=True,
ignore_field=['experiment_relation',