MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / initial_load_meta

Function initial_load_meta

tools/metadata_loader/main.py:107–154  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

105
106
107def initial_load_meta(args):
108 config = get_config()
109
110 storage_url = config["BLOB_STORAGE_ACCOUNT_URL"]
111 storage_sas = config["BLOB_STORAGE_SAS_KEY"]
112 blob_service_client = BlobServiceClient(
113 account_url=storage_url, credential=storage_sas
114 )
115 container_client = blob_service_client.get_container_client(
116 container=args.containerName
117 )
118
119 blob_list = container_client.list_blobs()
120 blob_names = [x.name for x in blob_list]
121
122 overall_response = True
123 for blob_name in blob_names:
124 basename = os.path.basename(blob_name)
125
126 parts = basename.split(".")
127 ext_index = len(parts) - 1
128
129 if len(parts) < 2 or parts[ext_index] != "sigmf-meta":
130 continue
131
132 dirname = os.path.dirname(blob_name)
133 filename_base = ".".join(parts[0:ext_index])
134 filepath = f"{dirname}/{filename_base}"
135
136 if f"{filepath}.sigmf-data" not in blob_names:
137 print(f"Skipping file {basename} because there is no sigmf-data.")
138 continue
139
140 blob_client = container_client.get_blob_client(blob=blob_name)
141 downloader = blob_client.download_blob(max_concurrency=1, encoding="UTF-8")
142 blob_text = downloader.readall()
143
144 resp = create_meta(
145 args.accountName, args.containerName, filepath, json.loads(blob_text)
146 )
147
148 print(
149 f"Load of {basename} into the database {'succeeded' if resp==201 else 'failed'}."
150 )
151
152 overall_response = overall_response and resp == 201
153
154 return overall_response
155
156
157def start():

Callers 1

test_initial_loadMethod · 0.90

Calls 7

list_blobsMethod · 0.80
download_blobMethod · 0.80
readallMethod · 0.80
get_configFunction · 0.70
create_metaFunction · 0.70
get_container_clientMethod · 0.45
get_blob_clientMethod · 0.45

Tested by 1

test_initial_loadMethod · 0.72