Skip to content

Commit

Permalink
Use direct script call
Browse files Browse the repository at this point in the history
  • Loading branch information
kjy5 committed Mar 20, 2024
1 parent fc51746 commit 3bb7d7a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
pull_request:

jobs:
build:
Expand All @@ -24,7 +25,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
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
50 changes: 23 additions & 27 deletions src/vbl_aquarium/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

0 comments on commit 3bb7d7a

Please sign in to comment.