Commit 461e5210 authored by dasharatha.vamshi's avatar dasharatha.vamshi

bug fix

parent a265efe0
...@@ -56,7 +56,8 @@ class AddtoModelStore: ...@@ -56,7 +56,8 @@ class AddtoModelStore:
] ]
} }
] ]
self.new_tag = self.first_run[0]
self.status = False
def move_files(self, file_name): def move_files(self, file_name):
try: try:
logger.info("started moving files from current to archived folder......") logger.info("started moving files from current to archived folder......")
...@@ -98,13 +99,17 @@ class AddtoModelStore: ...@@ -98,13 +99,17 @@ class AddtoModelStore:
logger.info("Updating metadata json file...............") logger.info("Updating metadata json file...............")
for i in data: for i in data:
if i['id'] == self.ilens_tag_hierarchy: if i['id'] == self.ilens_tag_hierarchy:
self.status = True
i['archived'].append(i['current_model']) i['archived'].append(i['current_model'])
i['current_model'] = self.update_current_model i['current_model'] = self.update_current_model
# print(data) if self.status:
return data return data
else:
logger.info("There is no site so add added the tag to the metadata json")
data.append(self.new_tag)
return data
except Exception as e: except Exception as e:
logger.info(traceback.format_exc()) logger.info(e)
raise KeyError(e)
def get_file_name_from_meta_data(self, data): def get_file_name_from_meta_data(self, data):
try: try:
...@@ -113,8 +118,8 @@ class AddtoModelStore: ...@@ -113,8 +118,8 @@ class AddtoModelStore:
if i['id'] == self.ilens_tag_hierarchy: if i['id'] == self.ilens_tag_hierarchy:
return i['current_model']['model_fl_name'] return i['current_model']['model_fl_name']
except Exception as e: except Exception as e:
logger.info(traceback.format_exc()) logger.info(e)
raise KeyError(e) return False
def run(self): def run(self):
try: try:
...@@ -131,12 +136,21 @@ class AddtoModelStore: ...@@ -131,12 +136,21 @@ class AddtoModelStore:
logger.info("Failed reading Json File") logger.info("Failed reading Json File")
logger.info(traceback.format_exc()) logger.info(traceback.format_exc())
old_model_name = self.get_file_name_from_meta_data(data) old_model_name = self.get_file_name_from_meta_data(data)
self.move_files(old_model_name) if old_model_name:
self.upload_to_blob() self.move_files(old_model_name)
data = self.update_meta_data(data) self.upload_to_blob()
json_object = json.dumps(data, indent=4) data = self.update_meta_data(data)
with open(self.query['metadata_file'], "w") as outfile: json_object = json.dumps(data, indent=4)
outfile.write(json_object) with open(self.query['metadata_file'], "w") as outfile:
outfile.write(json_object)
else:
logger.info("There is no model for this site")
self.upload_to_blob()
data = self.update_meta_data(data)
json_object = json.dumps(data, indent=4)
with open(self.query['metadata_file'], "w") as outfile:
outfile.write(json_object)
else: else:
logger.info( logger.info(
"metadata json file is not present so created metadata json file at " + self.query['metadata_file']) "metadata json file is not present so created metadata json file at " + self.query['metadata_file'])
......
[ [
{ {
"id": "site1", "id": "site-new",
"current_model": { "current_model": {
"model_name": "randomforest", "model_name": "randomforest",
"model_params": null, "model_params": null,
"training_date": "2021-03-11", "training_date": "2021-03-11",
"framework": null, "framework": null,
"serializedObjectType": "pkl", "serializedObjectType": "pkl",
"model_fl_name": "model_9547643f_59d89573.pkl" "model_fl_name": "model_78a80044.pkl"
}, },
"archived": [ "archived": [
{ {
"model_name": "randomforest", "model_name": "randomforest",
"model_params": null, "model_params": null,
"training_date": "2021-03-10", "training_date": "2021-03-11",
"framework": null, "framework": null,
"serializedObjectType": "pkl", "serializedObjectType": "pkl",
"model_fl_name": "model_111175b9.pkl" "model_fl_name": "model_48956f4d.pkl"
},
{
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_3f0d66a2.pkl"
},
{
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_7f17bf54.pkl"
},
{
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_07080eaa.pkl"
} }
] ]
},
{
"id": "site-new1",
"current_model": {
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-11",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_faed1e93.pkl"
},
"archived": []
} }
] ]
\ No newline at end of file
{
"ilens_tag_hierarchy": "site-new"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment