diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a909bb..a7d6d3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: run: pip install . - name: 🛠️ Build - run: ./vbl_aquarium_build + run: python src/vbl_aquarium/build.py - name: 📤 PR changes uses: peter-evans/create-pull-request@v6 diff --git a/pyproject.toml b/pyproject.toml index 9853b02..88fecea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,9 +36,6 @@ Documentation = "https://github.com/VirtualBrainLab/vbl-aquarium/blob/main/READM Issues = "https://github.com/VirtualBrainLab/vbl-aquarium/issues" Source = "https://github.com/VirtualBrainLab/vbl-aquarium" -[project.scripts] -vbl_aquarium_build = "vbl_aquarium.build:main" - [tool.hatch.version] path = "src/vbl_aquarium/__about__.py" diff --git a/src/vbl_aquarium/build.py b/src/vbl_aquarium/build.py index 64be5d3..eaa6b00 100644 --- a/src/vbl_aquarium/build.py +++ b/src/vbl_aquarium/build.py @@ -9,39 +9,35 @@ from vbl_aquarium.utils.vbl_base_model import VBLBaseModel -def main(): - def remove_ignored_classes(module): - return [c for c in get_classes(module) if c not in ignored_classes] +def remove_ignored_classes(module): + return [c for c in get_classes(module) if c not in ignored_classes] - ignored_classes = get_classes(unity) - ignored_classes.append(Enum) - ignored_classes.append(VBLBaseModel) - unity_class_names = [x.__name__ for x in get_classes(unity)] - module_list = [generic, urchin, logging, pinpoint, ephys_link, dock] - folder_prefix = ["generic", "urchin", "logging", "pinpoint", "ephys_link", "dock"] +ignored_classes = get_classes(unity) +ignored_classes.append(Enum) +ignored_classes.append(VBLBaseModel) +unity_class_names = [x.__name__ for x in get_classes(unity)] - cdir = dirname(abspath(__file__)) +module_list = [generic, urchin, logging, pinpoint, ephys_link, dock] +folder_prefix = ["generic", "urchin", "logging", "pinpoint", "ephys_link", "dock"] - for _, (module, cfolder) in enumerate(zip(module_list, folder_prefix)): - classes = remove_ignored_classes(module) +cdir = dirname(abspath(__file__)) - for cclass in classes: - if cclass.__name__ not in unity_class_names: - path = f"{cdir}/../../models/schemas/{cfolder}" - if not exists(path): - makedirs(path) +for _, (module, cfolder) in enumerate(zip(module_list, folder_prefix)): + classes = remove_ignored_classes(module) - with open(f"{path}/{cclass.__name__}.json", "w") as f: - f.write(dumps(cclass.model_json_schema())) + for cclass in classes: + if cclass.__name__ not in unity_class_names: + path = f"{cdir}/../../models/schemas/{cfolder}" + if not exists(path): + makedirs(path) - path = f"{cdir}/../../models/csharp/{cfolder}" - if not exists(path): - makedirs(path) + with open(f"{path}/{cclass.__name__}.json", "w") as f: + f.write(dumps(cclass.model_json_schema())) - with open(f"{path}/{cclass.__name__}.cs", "w") as f: - f.write(pydantic_to_csharp(cclass, cclass.model_json_schema())) + path = f"{cdir}/../../models/csharp/{cfolder}" + if not exists(path): + makedirs(path) - -if __name__ == "__main__": - main() + with open(f"{path}/{cclass.__name__}.cs", "w") as f: + f.write(pydantic_to_csharp(cclass, cclass.model_json_schema()))