Skip to content

Conversation

yuji38kwmt
Copy link
Collaborator

@yuji38kwmt yuji38kwmt commented Aug 26, 2021

SimpleAnnotationDetailクラスのdataプロパティをdictからdataclassに変換できるようにするため、dataプロパティを変換する関数を渡せるようにしました。

以下のクラスのparseメソッドが変更対象です。

  • SimpleAnnotationParser
  • FullAnnotationParser
    def convert_deitail_data(self, dict_data):
        if dict_data["_type"] == "Points":
            dict_data["type"] = dict_data["_type"]
            return FullAnnotationDataPoints.from_dict(dict_data)
        else:
            return dict_data

    def test_parse_for_zip(self):
        zip_path = Path(test_dir / "simple-annotation.zip")
        with zipfile.ZipFile(zip_path) as zip_file:
            parser = SimpleAnnotationZipParser(zip_file, "sample_1/c86205d1-bdd4-4110-ae46-194e661d622b.json")

            simple_annotation2 = parser.parse(self.convert_deitail_data)
            assert type(simple_annotation2.details[0].data) == FullAnnotationDataPoints

@yuji38kwmt yuji38kwmt changed the title Add parser ‘SimpleAnnotationParser.parse‘:SimpleAnnotationDetailクラスのdataプロパティを変換する関数を指定できるようにする Aug 26, 2021
@yuji38kwmt yuji38kwmt merged commit 2ad49c4 into master Aug 27, 2021
@yuji38kwmt yuji38kwmt deleted the add-parser branch August 27, 2021 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant