Skip to content

Commit cda549f

Browse files
committed
updates
1 parent cd61900 commit cda549f

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

expansion/expansion.py

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,9 @@ def delete_records(self, uuids, project_id, chunk_size=200, backup=False):
926926
results["responses"] = responses
927927
results["errors"] = errors
928928
print("\tFinished record deletion script.")
929-
929+
if len(success) > 0:
930+
print("Successfully deleted {} records.".format(len(success)))
931+
self.nuked()
930932
return results
931933

932934
def delete_node(self, node, project_id, chunk_size=200):
@@ -1043,6 +1045,7 @@ def delete_project(self, project_id, root_node="project", chunk_size=200, nuke_p
10431045
print("Successfully deleted the project '{}'".format(project_id))
10441046
self.nuked()
10451047
else:
1048+
self.nuked()
10461049
print("\n\nSuccessfully deleted all nodes in the project '{}'.\nIf you'd like to delete the project node itself, then add the flag 'nuke_project=True'.".format(project_id))
10471050

10481051

@@ -2781,6 +2784,9 @@ def delete_indexd_records(self,irecs):
27812784
else:
27822785
failure.append(guid)
27832786
print("{}/{} {}: Failed to delete '{}'.".format(count,total,response.status_code,guid))
2787+
if len(success) > 0:
2788+
print("Successfully deleted {} indexd records.".format(len(success)))
2789+
self.nuked()
27842790
return {'success':success,'failure':failure}
27852791

27862792

@@ -3137,6 +3143,9 @@ def delete_uploaded_files(self, guids):
31373143
print("({}/{}) Error deleting GUID {}:".format(count,total,guid))
31383144
print(response.reason)
31393145
failed.append(guid)
3146+
if len(deleted) > 0:
3147+
print("Successfully deleted {} uploaded files.".format(len(deleted)))
3148+
self.nuked()
31403149
return({'deleted':deleted,'failed':failed})
31413150

31423151

@@ -4101,7 +4110,9 @@ def delete_mds(self,guids):
41014110
else:
41024111
failed.append(guid)
41034112
print("({}/{}) FAILED to delete '{}' from MDS.".format(count, total, guid))
4104-
4113+
if len(deleted) > 0:
4114+
print("Successfully deleted {} metadata records.".format(len(deleted)))
4115+
self.nuked()
41054116
return {"deleted":deleted,"failed":failed}
41064117

41074118

@@ -5045,7 +5056,9 @@ def create_mock_tsv(self,
50455056
"object_id",
50465057
"storage_urls"],
50475058
mfiles=None,
5048-
submit_tsv=False
5059+
submit_tsv=False,
5060+
minimum=1,
5061+
maximum=20
50495062
):
50505063
"""
50515064
Create mock / simulated data in a submission TSV for a node in the data dictionary.
@@ -5060,22 +5073,25 @@ def create_mock_tsv(self,
50605073
excluded_props(list): a list of properties in data dictionary to ignore / exclude from the TSV columns
50615074
mfiles(dict): a dictionary of mock data files created using func create_mock_files()
50625075
submit_tsv(boolean): if true, will use sdk to submit the file via sheepdog
5063-
"""
5076+
50645077
############################################################
50655078
############################################################
50665079
# Use these settings for testing, comment out when actually running as function or in SDK.
50675080
############################################################
5068-
# node = 'cr_series_file'
5069-
# count = 3
5070-
# outdir = "/Users/christopher/Documents/Notes/MIDRC/annotations/sample_data/DEV-test/script_tsvs"
5071-
# filename = "{}_mock_{}.tsv".format(node,dd_version) # override for testing, comment out
5072-
# links = self.list_links(node, dd)
5073-
# parent_tsvs = {link:"{}_mock_{}.tsv".format(link_targets[link],dd_version) for link in links}
5074-
# links = None # for testing comment this out later
5081+
dd = sub.get_dictionary_all()
5082+
dd_version = dd["_settings"]["_dict_version"]
5083+
node = 'cr_series_file'
5084+
count = 3
5085+
outdir = "/Users/christopher/Documents/Notes/MIDRC/annotations/sample_data/DEV-test/script_tsvs"
5086+
filename = "{}_mock_{}.tsv".format(node,dd_version) # override for testing, comment out
5087+
links = self.list_links(node, dd)
5088+
5089+
parent_tsvs = {link:"{}/{}_mock_{}.tsv".format(outdir,link_targets[link],dd_version) for link in links}
5090+
links = None # for testing comment this out later
50755091
############################################################
50765092
############################################################
50775093
############################################################
5078-
5094+
"""
50795095
# get the data dictionary and version number
50805096
dd_version = dd["_settings"]["_dict_version"]
50815097

@@ -5155,6 +5171,10 @@ def create_mock_tsv(self,
51555171
array_type = dd[node]['properties'][prop]['items']
51565172
if 'type' in dd[node]['properties'][prop]['items']:
51575173
array_type = dd[node]['properties'][prop]['items']['type']
5174+
if 'minimum' in dd[node]['properties'][prop]['items']:
5175+
minimum = dd[node]['properties'][prop]['items']['minimum']
5176+
if 'maximum' in dd[node]['properties'][prop]['items']:
5177+
maximum = dd[node]['properties'][prop]['items']['maximum']
51585178
if array_type == "string":
51595179
data[prop] = ["test {}, test {}".format(prop,prop)] * count
51605180
# array_values = ["test {}, test {}".format(prop,prop)] * count
@@ -5179,9 +5199,17 @@ def create_mock_tsv(self,
51795199
available_types = cycle([True,False])
51805200
data[prop] = [next(available_types)for i in range(count)]
51815201
elif prop_type == "integer":
5182-
data[prop] = list(np.random.randint(low=1, high=89, size=(count)))
5202+
if 'minimum' in dd[node]['properties'][prop]:
5203+
minimum = dd[node]['properties'][prop]['minimum']
5204+
if 'maximum' in dd[node]['properties'][prop]:
5205+
maximum = dd[node]['properties'][prop]['maximum']
5206+
data[prop] = list(np.random.randint(low=minimum, high=maximum, size=(count)))
51835207
elif prop_type == "number":
5184-
data[prop] = [ '%.2f' % elem for elem in list(np.random.uniform(low=1, high=89, size=count))]
5208+
if 'minimum' in dd[node]['properties'][prop]:
5209+
minimum = dd[node]['properties'][prop]['minimum']
5210+
if 'maximum' in dd[node]['properties'][prop]:
5211+
maximum = dd[node]['properties'][prop]['maximum']
5212+
data[prop] = [ '%.2f' % elem for elem in list(np.random.uniform(low=minimum, high=maximum, size=count))]
51855213

51865214
elif 'enum' in dd[node]['properties'][prop]:
51875215
enums = dd[node]['properties'][prop]['enum']

0 commit comments

Comments
 (0)