"torchvision/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "2e23e477488384cdaf56619433338f1a0169b747"
Commit f4fcff31 authored by Shiyu Dong's avatar Shiyu Dong Committed by Facebook GitHub Bot
Browse files

Check if new_ds_name registered to MetadataCatalog before removing

Summary:
As title, sometimes new_ds_name is not registered so it crashes the program when calling remove(). Adding a check.
A side effect to this is if it's not registered, get() method will register it first and then remove() will remove it from registery.

Reviewed By: ppwwyyxx

Differential Revision: D31049303

fbshipit-source-id: 149168fb89fd3b661b60717ff2aafa7a9bd52849
parent e992359c
...@@ -150,7 +150,8 @@ class AdhocCOCODataset(AdhocDataset): ...@@ -150,7 +150,8 @@ class AdhocCOCODataset(AdhocDataset):
metadata_dict["name"] = self.new_ds_name metadata_dict["name"] = self.new_ds_name
if "json_file" in metadata_dict: if "json_file" in metadata_dict:
metadata_dict["json_file"] = tmp_file metadata_dict["json_file"] = tmp_file
MetadataCatalog.remove(self.new_ds_name) if MetadataCatalog.get(self.new_ds_name):
MetadataCatalog.remove(self.new_ds_name)
MetadataCatalog.get(self.new_ds_name).set(**metadata_dict) MetadataCatalog.get(self.new_ds_name).set(**metadata_dict)
def cleanup(self): def cleanup(self):
......
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