Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build call in workflow #10

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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()))