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

bug fix

parent a265efe0
......@@ -56,7 +56,8 @@ class AddtoModelStore:
]
}
]
self.new_tag = self.first_run[0]
self.status = False
def move_files(self, file_name):
try:
logger.info("started moving files from current to archived folder......")
......@@ -98,13 +99,17 @@ class AddtoModelStore:
logger.info("Updating metadata json file...............")
for i in data:
if i['id'] == self.ilens_tag_hierarchy:
self.status = True
i['archived'].append(i['current_model'])
i['current_model'] = self.update_current_model
# print(data)
if self.status:
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:
logger.info(traceback.format_exc())
raise KeyError(e)
logger.info(e)
def get_file_name_from_meta_data(self, data):
try:
......@@ -113,8 +118,8 @@ class AddtoModelStore:
if i['id'] == self.ilens_tag_hierarchy:
return i['current_model']['model_fl_name']
except Exception as e:
logger.info(traceback.format_exc())
raise KeyError(e)
logger.info(e)
return False
def run(self):
try:
......@@ -131,12 +136,21 @@ class AddtoModelStore:
logger.info("Failed reading Json File")
logger.info(traceback.format_exc())
old_model_name = self.get_file_name_from_meta_data(data)
if old_model_name:
self.move_files(old_model_name)
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:
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:
logger.info(
"metadata json file is not present so created metadata json file at " + self.query['metadata_file'])
......
[
{
"id": "site1",
"id": "site-new",
"current_model": {
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-11",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_9547643f_59d89573.pkl"
"model_fl_name": "model_78a80044.pkl"
},
"archived": [
{
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_111175b9.pkl"
},
{
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"training_date": "2021-03-11",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_3f0d66a2.pkl"
"model_fl_name": "model_48956f4d.pkl"
}
]
},
{
"id": "site-new1",
"current_model": {
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"training_date": "2021-03-11",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_7f17bf54.pkl"
"model_fl_name": "model_faed1e93.pkl"
},
{
"model_name": "randomforest",
"model_params": null,
"training_date": "2021-03-10",
"framework": null,
"serializedObjectType": "pkl",
"model_fl_name": "model_07080eaa.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