Browse Source

working whitelist for stage

cjs3
Stephen Lorenz 3 years ago
parent
commit
4ec6929c67
  1. 5
      cjs/cjs/core/interface.py
  2. 18
      cjs/cjs/database.py
  3. 4
      cjsd/cjsd/core/database.py
  4. 2
      cjsd/cjsd/resources/database.py
  5. 5
      debug/debug-whitelist.json

5
cjs/cjs/core/interface.py

@ -138,10 +138,11 @@ class DatabaseInterface(WebInterface):
data = self.post('/database/clear', payload)
return data
def stage(self, database, batch):
def stage(self, database, batch, whitelist):
payload = {
'database': database,
'batch': batch
'batch': batch,
'whitelist': whitelist
}
data = self.post('/database/stage', payload)
return data

18
cjs/cjs/database.py

@ -110,6 +110,7 @@ def upload(ctx, database_name, input_file):
# read json data into a dictionary
input_data = read_json(input_file)
# print an overall progress bar for each dataset
with click.progressbar(input_data.items()) as bar:
for key, value in bar:
@ -137,8 +138,16 @@ def clear(ctx, database_name):
@cli.command()
@click.argument('database_name')
@click.argument('batch_name')
@click.option(
'--whitelist_file',
type=click.Path(
file_okay=True,
dir_okay=False,
resolve_path=True
),
help='Set a whitelist of the only jobs that should be staged.')
@click.pass_context
def stage(ctx, database_name, batch_name):
def stage(ctx, database_name, batch_name, whitelist_file):
'''
Generate jobs.\f
@ -147,8 +156,13 @@ def stage(ctx, database_name, batch_name):
database_name: Name of an pre-existing database.
batch_name: Name used to identify a staged batch.
'''
if whitelist_file:
with open(whitelist_file, 'r') as fh:
whitelist = json.load(fh)
interface = ctx.obj['interface']
interface.stage(database_name, batch_name)
interface.stage(database_name, batch_name, whitelist)
@cli.command()
@click.argument('database_name')

4
cjsd/cjsd/core/database.py

@ -377,8 +377,8 @@ def stage_jobs(name, batch_name, whitelist):
ename, cname = row
evidence_table = sess.query(EvidenceTable).filter(EvidenceTable.name == ename).first()
comparison_table = sess.query(ComparisonTable).filter(ComparisonTable.name == cname).first()
test_table = sess.query(TestTable).filter(TestTable.evidence_id == evidence_table.id_).filter(TestTable.comparison_id == comparison_id == comparison_table.id_).first()
job_list.append(JobTable(table_table.id_, batch_table.id_))
test_table = sess.query(TestTable).filter(TestTable.evidence_id == evidence_table.id_).filter(TestTable.comparison_id == comparison_table.id_).first()
job_list.append(JobTable(test_table.id_, batch_table.id_))
else:
test_list = sess.query(TestTable).all()
for Test in test_list:

2
cjsd/cjsd/resources/database.py

@ -344,6 +344,8 @@ class StageResource:
whitelist = req.media['whitelist']
except:
pass
print(whitelist)
try:
# determine the existing database's location
database_path = database_location(database_name)

5
debug/debug-whitelist.json

@ -0,0 +1,5 @@
[
["reqbt-1", "reqbt-1-1"],
["reqbt-1", "reqbt-1-2"]
]
Loading…
Cancel
Save