Skip to content

Commit

Permalink
fix: build call in workflow (#10)
Browse files Browse the repository at this point in the history
* Use direct script call

* Remove PR trigger
  • Loading branch information
kjy5 authored Mar 20, 2024
1 parent fc51746 commit 2b1c3d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 31 deletions.
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()))

0 comments on commit 2b1c3d1

Please sign in to comment.