aiaccel 2025.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. aiaccel-2025.4/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  2. aiaccel-2025.4/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  3. aiaccel-2025.4/.github/workflows/ci.yaml +30 -0
  4. aiaccel-2025.4/.github/workflows/gh-pages.yaml +50 -0
  5. aiaccel-2025.4/.github/workflows/lint.yaml +36 -0
  6. aiaccel-2025.4/.gitignore +134 -0
  7. aiaccel-2025.4/.pre-commit-config.yaml +29 -0
  8. aiaccel-2025.4/LICENSE +21 -0
  9. aiaccel-2025.4/MANIFEST.in +2 -0
  10. aiaccel-2025.4/PKG-INFO +80 -0
  11. aiaccel-2025.4/README.md +31 -0
  12. aiaccel-2025.4/aiaccel/__init__.py +3 -0
  13. aiaccel-2025.4/aiaccel/config/__init__.py +19 -0
  14. aiaccel-2025.4/aiaccel/config/config.py +181 -0
  15. aiaccel-2025.4/aiaccel/config/git.py +155 -0
  16. aiaccel-2025.4/aiaccel/hpo/__init__.py +0 -0
  17. aiaccel-2025.4/aiaccel/hpo/algorithms/__init__.py +7 -0
  18. aiaccel-2025.4/aiaccel/hpo/algorithms/nelder_mead_algorithm.py +282 -0
  19. aiaccel-2025.4/aiaccel/hpo/apps/__init__.py +1 -0
  20. aiaccel-2025.4/aiaccel/hpo/apps/config/__init__.py +0 -0
  21. aiaccel-2025.4/aiaccel/hpo/apps/config/default.yaml +14 -0
  22. aiaccel-2025.4/aiaccel/hpo/apps/config/resumable.yaml +8 -0
  23. aiaccel-2025.4/aiaccel/hpo/apps/optimize.py +182 -0
  24. aiaccel-2025.4/aiaccel/hpo/optuna/__init__.py +0 -0
  25. aiaccel-2025.4/aiaccel/hpo/optuna/samplers/__init__.py +3 -0
  26. aiaccel-2025.4/aiaccel/hpo/optuna/samplers/nelder_mead_sampler.py +303 -0
  27. aiaccel-2025.4/aiaccel/hpo/optuna/suggest_wrapper.py +88 -0
  28. aiaccel-2025.4/aiaccel/torch/__init__.py +0 -0
  29. aiaccel-2025.4/aiaccel/torch/apps/__init__.py +0 -0
  30. aiaccel-2025.4/aiaccel/torch/apps/config/train_base.yaml +9 -0
  31. aiaccel-2025.4/aiaccel/torch/apps/config/train_ddp.yaml +9 -0
  32. aiaccel-2025.4/aiaccel/torch/apps/train.py +68 -0
  33. aiaccel-2025.4/aiaccel/torch/datasets/__init__.py +12 -0
  34. aiaccel-2025.4/aiaccel/torch/datasets/cached_dataset.py +113 -0
  35. aiaccel-2025.4/aiaccel/torch/datasets/file_cached_dataset.py +55 -0
  36. aiaccel-2025.4/aiaccel/torch/datasets/hdf5_dataset.py +94 -0
  37. aiaccel-2025.4/aiaccel/torch/datasets/scatter_dataset.py +46 -0
  38. aiaccel-2025.4/aiaccel/torch/h5py/__init__.py +5 -0
  39. aiaccel-2025.4/aiaccel/torch/h5py/hdf5_writer.py +181 -0
  40. aiaccel-2025.4/aiaccel/torch/lightning/__init__.py +4 -0
  41. aiaccel-2025.4/aiaccel/torch/lightning/abci_environment.py +67 -0
  42. aiaccel-2025.4/aiaccel/torch/lightning/datamodules/__init__.py +3 -0
  43. aiaccel-2025.4/aiaccel/torch/lightning/datamodules/single_datamodule.py +95 -0
  44. aiaccel-2025.4/aiaccel/torch/lightning/opt_lightning_module.py +66 -0
  45. aiaccel-2025.4/docs/Makefile +14 -0
  46. aiaccel-2025.4/docs/image/favicon.ico +0 -0
  47. aiaccel-2025.4/docs/image/logo_aiaccel.png +0 -0
  48. aiaccel-2025.4/docs/make.bat +35 -0
  49. aiaccel-2025.4/docs/source/_static/custom_color.css +15 -0
  50. aiaccel-2025.4/docs/source/api_reference/config.rst +28 -0
  51. aiaccel-2025.4/docs/source/api_reference/hpo.rst +48 -0
  52. aiaccel-2025.4/docs/source/api_reference/index.rst +9 -0
  53. aiaccel-2025.4/docs/source/api_reference/torch.rst +57 -0
  54. aiaccel-2025.4/docs/source/conf.py +106 -0
  55. aiaccel-2025.4/docs/source/contribution_guide/coding_styles.md +65 -0
  56. aiaccel-2025.4/docs/source/contribution_guide/documentation.md +30 -0
  57. aiaccel-2025.4/docs/source/contribution_guide/index.rst +13 -0
  58. aiaccel-2025.4/docs/source/contribution_guide/issues.md +18 -0
  59. aiaccel-2025.4/docs/source/contribution_guide/pull_requests.md +72 -0
  60. aiaccel-2025.4/docs/source/contribution_guide/tests.md +57 -0
  61. aiaccel-2025.4/docs/source/index.rst +62 -0
  62. aiaccel-2025.4/docs/source/user_guide/config.rst +148 -0
  63. aiaccel-2025.4/docs/source/user_guide/hpo.rst +388 -0
  64. aiaccel-2025.4/docs/source/user_guide/index.md +15 -0
  65. aiaccel-2025.4/docs/source/user_guide/torch.rst +89 -0
  66. aiaccel-2025.4/examples/hpo/samplers/README.md +28 -0
  67. aiaccel-2025.4/examples/hpo/samplers/README_ja.md +42 -0
  68. aiaccel-2025.4/examples/hpo/samplers/coco/README.md +59 -0
  69. aiaccel-2025.4/examples/hpo/samplers/coco/README_ja.md +63 -0
  70. aiaccel-2025.4/examples/hpo/samplers/coco/experiment_coco.py +185 -0
  71. aiaccel-2025.4/examples/hpo/samplers/coco/main_parallel_coco.py +49 -0
  72. aiaccel-2025.4/examples/hpo/samplers/coco/objective.sh +11 -0
  73. aiaccel-2025.4/examples/hpo/samplers/coco/plot.py +96 -0
  74. aiaccel-2025.4/examples/hpo/samplers/coco/result_bbob_dim_vs_value-fopt_parallel.png +0 -0
  75. aiaccel-2025.4/examples/hpo/samplers/example.py +23 -0
  76. aiaccel-2025.4/examples/hpo/samplers/example_enqueue.py +26 -0
  77. aiaccel-2025.4/examples/hpo/samplers/example_parallel.py +27 -0
  78. aiaccel-2025.4/examples/hpo/samplers/example_sub_sampler.py +29 -0
  79. aiaccel-2025.4/examples/job/optuna/config.yaml +21 -0
  80. aiaccel-2025.4/examples/job/optuna/config_abci.yaml +19 -0
  81. aiaccel-2025.4/examples/job/optuna/objective.py +3 -0
  82. aiaccel-2025.4/examples/torch/README.md +13 -0
  83. aiaccel-2025.4/examples/torch/common_config.ymal +60 -0
  84. aiaccel-2025.4/examples/torch/resnet50/config.yaml +3 -0
  85. aiaccel-2025.4/examples/torch/resnet50/train.sh +16 -0
  86. aiaccel-2025.4/examples/torch/resnet50_ddp/config.yaml +6 -0
  87. aiaccel-2025.4/examples/torch/resnet50_ddp/train.sh +21 -0
  88. aiaccel-2025.4/examples/torch/torchvision_task.py +56 -0
  89. aiaccel-2025.4/mypy.ini +24 -0
  90. aiaccel-2025.4/pyproject.toml +103 -0
  91. aiaccel-2025.4/tests/config/test_base.yaml +6 -0
  92. aiaccel-2025.4/tests/config/test_conf.yaml +13 -0
  93. aiaccel-2025.4/tests/config/test_config.py +64 -0
  94. aiaccel-2025.4/tests/config/test_config_assets/print_config.txt +7 -0
  95. aiaccel-2025.4/tests/hpo/algorithms/test_nelder_mead_algorithm.py +250 -0
  96. aiaccel-2025.4/tests/hpo/apps/main/config.yaml +38 -0
  97. aiaccel-2025.4/tests/hpo/apps/main/in_memory.yaml +25 -0
  98. aiaccel-2025.4/tests/hpo/apps/main/objective_for_test.py +85 -0
  99. aiaccel-2025.4/tests/hpo/apps/main/test_resume.py +250 -0
  100. aiaccel-2025.4/tests/hpo/optuna/samplers/results_ackley.csv +31 -0
  101. aiaccel-2025.4/tests/hpo/optuna/samplers/results_ackley_int.csv +31 -0
  102. aiaccel-2025.4/tests/hpo/optuna/samplers/results_ackley_logscale.csv +31 -0
  103. aiaccel-2025.4/tests/hpo/optuna/samplers/results_ackley_step.csv +31 -0
  104. aiaccel-2025.4/tests/hpo/optuna/samplers/results_ackley_sub_sampler.csv +151 -0
  105. aiaccel-2025.4/tests/hpo/optuna/samplers/results_shpere_enqueue.csv +151 -0
  106. aiaccel-2025.4/tests/hpo/optuna/samplers/results_shpere_parallel.csv +31 -0
  107. aiaccel-2025.4/tests/hpo/optuna/samplers/test_nelder_mead_sampler.py +590 -0
  108. aiaccel-2025.4/tests/hpo/optuna/test_suggest_wrapper.py +57 -0
  109. aiaccel-2025.4/tests/torch/datasets/test_cached_dataset.py +24 -0
  110. aiaccel-2025.4/tests/torch/datasets/test_hdf5_dataset.py +50 -0
  111. aiaccel-2025.4/tests/torch/datasets/test_hdf5_dataset_assets/dataset.hdf5 +0 -0
  112. aiaccel-2025.4/tests/torch/datasets/test_scatter_dataset.py +27 -0
  113. aiaccel-2025.4/tests/torch/lightning/test_abci_environment.py +40 -0
  114. aiaccel-2025.4/typings/h5py.pyi +35 -0
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main", "develop/*"]
6
+ pull_request:
7
+
8
+ jobs:
9
+ ci:
10
+ name: CI
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: ['ubuntu-22.04']
15
+ python-version: ['3.10']
16
+ test_target: ['config', 'hpo', 'torch']
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+ cache: 'pip'
23
+ cache-dependency-path: pyproject.toml
24
+ - name: Install dependencies
25
+ run: |
26
+ pip install --upgrade pip
27
+ pip install -e .[dev,github-actions]
28
+ - name: Run pytest
29
+ run: pytest -v --cov=aiaccel/${{ strategy.target }} --cov-branch --cov-report=term-missing tests/${{ strategy.target }}
30
+
@@ -0,0 +1,50 @@
1
+ name: GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches: ["main", "develop/*"]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+ pages: write
12
+ id-token: write
13
+
14
+ concurrency:
15
+ group: "pages"
16
+ cancel-in-progress: false
17
+
18
+ jobs:
19
+ build:
20
+ name: GitHub Pages (Build)
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: actions/setup-python@v5
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ python -m pip install .[dev,github-actions]
29
+ - name: Sphinx build
30
+ run: |
31
+ sphinx-apidoc --maxdepth 2 -f -o ./docs/source/api_reference/ ./aiaccel/
32
+ cd docs
33
+ make html
34
+ - name: Upload artifact
35
+ uses: actions/upload-pages-artifact@v3
36
+ with:
37
+ path: docs/build/html/
38
+
39
+ deploy:
40
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
41
+ name: GitHub Pages (Deploy)
42
+ environment:
43
+ name: github-pages
44
+ url: ${{ steps.deployment.outputs.page_url }}
45
+ runs-on: ubuntu-latest
46
+ needs: build
47
+ steps:
48
+ - name: Deploy to GitHub Pages
49
+ id: deployment
50
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,36 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: ["main", "develop/*"]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ name: Lint
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: ['ubuntu-22.04']
15
+ python-version: ['3.10']
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+ cache: 'pip'
22
+ cache-dependency-path: pyproject.toml
23
+ - name: Install dependencies
24
+ run: |
25
+ pip install --upgrade pip
26
+ pip install .[dev,github-actions]
27
+ - name: Perform ruff
28
+ run: |
29
+ ruff check
30
+ ruff format --check
31
+ - name: Perform mypy
32
+ run: |
33
+ mypy --config-file mypy.ini .
34
+ - name: Perform docstrfmt
35
+ run: |
36
+ docstrfmt --check docs/source/
@@ -0,0 +1,134 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ # lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+ MANIFEST
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+ .pytest_cache/
49
+
50
+ # Translations
51
+ *.mo
52
+ *.pot
53
+
54
+ # Django stuff:
55
+ *.log
56
+ local_settings.py
57
+ db.sqlite3
58
+
59
+ # Flask stuff:
60
+ instance/
61
+ .webassets-cache
62
+
63
+ # Scrapy stuff:
64
+ .scrapy
65
+
66
+ # Sphinx documentation
67
+ docs/_build/
68
+
69
+ # PyBuilder
70
+ target/
71
+
72
+ # Jupyter Notebook
73
+ .ipynb_checkpoints
74
+
75
+ # pyenv
76
+ .python-version
77
+
78
+ # celery beat schedule file
79
+ celerybeat-schedule
80
+
81
+ # SageMath parsed files
82
+ *.sage.py
83
+
84
+ # Environments
85
+ .env
86
+ .venv
87
+ env/
88
+ venv/
89
+ ENV/
90
+ env.bak/
91
+ venv.bak/
92
+
93
+ # Spyder project settings
94
+ .spyderproject
95
+ .spyproject
96
+
97
+ # Rope project settings
98
+ .ropeproject
99
+
100
+ # mkdocs documentation
101
+ /site
102
+
103
+ # mypy
104
+ .mypy_cache/
105
+
106
+ # application workspace
107
+ /work/
108
+ work_aiaccel/
109
+
110
+ # vscode
111
+ .vscode
112
+ *.code-workspace
113
+
114
+ # document
115
+ docs/build/html
116
+ docs/source/api_reference/
117
+ !docs/source/api_reference/index.rst
118
+ !docs/source/api_reference/torch.rst
119
+ !docs/source/api_reference/hpo.rst
120
+
121
+ # IntelliJ
122
+ .idea
123
+
124
+ # Docker
125
+ .devcontainer
126
+ Dockerfile
127
+
128
+ # ruff
129
+ .ruff_cache
130
+
131
+ # example
132
+ examples/hpo/samplers/coco/exdata
133
+ examples/hpo/samplers/coco/*/optuna_csv
134
+ examples/hpo/samplers/coco/*/step_csv
@@ -0,0 +1,29 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.3.5
4
+ hooks:
5
+ - id: ruff
6
+ args: [--fix]
7
+ - id: ruff-format
8
+ - repo: https://github.com/pre-commit/mirrors-mypy
9
+ rev: v1.9.0
10
+ hooks:
11
+ - id: mypy
12
+ language: system
13
+ args: [--config-file, mypy.ini]
14
+ - repo: local
15
+ hooks:
16
+ - id: pytest
17
+ name: pytest
18
+ entry: pytest -s -v -x --cov=aiaccel/ tests/
19
+ stages: [push]
20
+ language: system
21
+ pass_filenames: false
22
+ always_run: true
23
+ - repo: https://github.com/LilSpazJoekp/docstrfmt
24
+ rev: v1.10.0
25
+ hooks:
26
+ - id: docstrfmt
27
+ args: [--check, docs/source/]
28
+ types_or: [rst]
29
+ exclude: docs/source/api_reference/generated
aiaccel-2025.4/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 National Institute of Advanced Industrial Science and Technology (AIST), Japan, All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include aiaccel/hpo/apps/config/*.yaml
2
+ include aiaccel/torch/apps/config/*.yaml
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiaccel
3
+ Version: 2025.4
4
+ Summary: AIST Toolkit for Accelerating Machine Learning Research
5
+ Author-email: AIST <onishi-masaki@aist.go.jp>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: optuna>=3.4.0
12
+ Requires-Dist: omegaconf
13
+ Requires-Dist: hydra-core
14
+ Requires-Dist: colorama
15
+ Requires-Dist: lightning>=2.2.1
16
+ Requires-Dist: torch>=2.2.0
17
+ Requires-Dist: h5py
18
+ Requires-Dist: dask-jobqueue
19
+ Requires-Dist: rich
20
+ Requires-Dist: mypy ; extra == "dev"
21
+ Requires-Dist: myst-parser ; extra == "dev"
22
+ Requires-Dist: pre-commit ; extra == "dev"
23
+ Requires-Dist: pytest ; extra == "dev"
24
+ Requires-Dist: pytest-cov ; extra == "dev"
25
+ Requires-Dist: pytest-mock ; extra == "dev"
26
+ Requires-Dist: pytest-subprocess ; extra == "dev"
27
+ Requires-Dist: ruff ; extra == "dev"
28
+ Requires-Dist: sphinx ; extra == "dev"
29
+ Requires-Dist: sphinxcontrib-jquery ; extra == "dev"
30
+ Requires-Dist: sphinx-intl ; extra == "dev"
31
+ Requires-Dist: sphinx-fontawesome ; extra == "dev"
32
+ Requires-Dist: sphinx-rtd-theme ; extra == "dev"
33
+ Requires-Dist: sphinx-copybutton ; extra == "dev"
34
+ Requires-Dist: pydata-sphinx-theme ; extra == "dev"
35
+ Requires-Dist: sphinx_design ; extra == "dev"
36
+ Requires-Dist: types-colorama ; extra == "dev"
37
+ Requires-Dist: types-PyYAML ; extra == "dev"
38
+ Requires-Dist: undecorated ; extra == "dev"
39
+ Requires-Dist: pandas ; extra == "dev"
40
+ Requires-Dist: pandas-stubs ; extra == "dev"
41
+ Requires-Dist: matplotlib ; extra == "dev"
42
+ Requires-Dist: docstrfmt ; extra == "dev"
43
+ Requires-Dist: pytest-github-actions-annotate-failures ; extra == "github-actions"
44
+ Project-URL: documentation, https://aistairc.github.io/aiaccel/
45
+ Project-URL: repository, https://github.com/aistairc/aiaccel
46
+ Provides-Extra: dev
47
+ Provides-Extra: github-actions
48
+
49
+ <div align="center"><img src="https://raw.githubusercontent.com/aistairc/aiaccel/master/docs/image/logo_aiaccel.png" width="600"/></div>
50
+ <div align="center">
51
+ <img src="https://img.shields.io/github/license/aistairc/aiaccel.svg" />
52
+ <img src="https://img.shields.io/badge/Python-3.10-blue" />
53
+ <a href="https://aistairc.github.io/aiaccel">
54
+ <img src="https://github.com/aistairc/aiaccel/actions/workflows/gh-pages.yaml/badge.svg" />
55
+ </a>
56
+ <img src="https://github.com/aistairc/aiaccel/actions/workflows/ci.yaml/badge.svg" />
57
+ </div>
58
+
59
+ # AIST Toolkit for Accelerating Machine Learning Research
60
+
61
+ * **Research-Oriented**: designed to accelerate your research cycles written in Python
62
+ * **HPC Optimized**: intended to use in HPC clusters, including [AI Bridging Cloud Infrastructure (ABCI)](https://abci.ai/)
63
+ * **Highly Modular**: designed to let you pick up any part of aiaccel for your research project
64
+
65
+ # Key Features
66
+ * [PyTorch/Lightning Toolkit](https://aistairc.github.io/aiaccel/api_reference/torch.html): training toolkit for HPC clusters.
67
+ * [Hyperparameter Optimization (HPO)](https://aistairc.github.io/aiaccel/api_reference/hpo.html): ready-to-use HPO algorithms/tools.
68
+ * [OmegaConf Utilities](https://aistairc.github.io/aiaccel/api_reference/config.html): OmegaConf-based config utilities.
69
+
70
+
71
+ # Installation
72
+ ```bash
73
+ pip install aiaccel
74
+ ```
75
+
76
+ # Acknowledgement
77
+ * Part of this software was developed in a project commissioned by the New Energy and Industrial Technology Development Organization (NEDO).
78
+ * Part of this software was developed by using ABCI 3.0 provided by AIST and AIST Solutions.
79
+ * Part of this software was developed by using the TSUBAME4.0 supercomputer at Institute of Science Tokyo.
80
+
@@ -0,0 +1,31 @@
1
+ <div align="center"><img src="https://raw.githubusercontent.com/aistairc/aiaccel/master/docs/image/logo_aiaccel.png" width="600"/></div>
2
+ <div align="center">
3
+ <img src="https://img.shields.io/github/license/aistairc/aiaccel.svg" />
4
+ <img src="https://img.shields.io/badge/Python-3.10-blue" />
5
+ <a href="https://aistairc.github.io/aiaccel">
6
+ <img src="https://github.com/aistairc/aiaccel/actions/workflows/gh-pages.yaml/badge.svg" />
7
+ </a>
8
+ <img src="https://github.com/aistairc/aiaccel/actions/workflows/ci.yaml/badge.svg" />
9
+ </div>
10
+
11
+ # AIST Toolkit for Accelerating Machine Learning Research
12
+
13
+ * **Research-Oriented**: designed to accelerate your research cycles written in Python
14
+ * **HPC Optimized**: intended to use in HPC clusters, including [AI Bridging Cloud Infrastructure (ABCI)](https://abci.ai/)
15
+ * **Highly Modular**: designed to let you pick up any part of aiaccel for your research project
16
+
17
+ # Key Features
18
+ * [PyTorch/Lightning Toolkit](https://aistairc.github.io/aiaccel/api_reference/torch.html): training toolkit for HPC clusters.
19
+ * [Hyperparameter Optimization (HPO)](https://aistairc.github.io/aiaccel/api_reference/hpo.html): ready-to-use HPO algorithms/tools.
20
+ * [OmegaConf Utilities](https://aistairc.github.io/aiaccel/api_reference/config.html): OmegaConf-based config utilities.
21
+
22
+
23
+ # Installation
24
+ ```bash
25
+ pip install aiaccel
26
+ ```
27
+
28
+ # Acknowledgement
29
+ * Part of this software was developed in a project commissioned by the New Energy and Industrial Technology Development Organization (NEDO).
30
+ * Part of this software was developed by using ABCI 3.0 provided by AIST and AIST Solutions.
31
+ * Part of this software was developed by using the TSUBAME4.0 supercomputer at Institute of Science Tokyo.
@@ -0,0 +1,3 @@
1
+ from importlib.metadata import version
2
+
3
+ __version__ = version(__package__)
@@ -0,0 +1,19 @@
1
+ from aiaccel.config.config import (
2
+ load_config,
3
+ overwrite_omegaconf_dumper,
4
+ pathlib2str_config,
5
+ print_config,
6
+ resolve_inherit,
7
+ )
8
+ from aiaccel.config.git import PackageGitStatus, collect_git_status_from_config, print_git_status
9
+
10
+ __all__ = [
11
+ "load_config",
12
+ "overwrite_omegaconf_dumper",
13
+ "pathlib2str_config",
14
+ "print_config",
15
+ "resolve_inherit",
16
+ "PackageGitStatus",
17
+ "collect_git_status_from_config",
18
+ "print_git_status",
19
+ ]
@@ -0,0 +1,181 @@
1
+ from typing import Any
2
+
3
+ import copy
4
+ from copy import deepcopy
5
+ from pathlib import Path
6
+ import re
7
+
8
+ from colorama import Fore
9
+ from omegaconf import DictConfig, ListConfig
10
+ from omegaconf import OmegaConf as oc # noqa:N813
11
+ from omegaconf._utils import OmegaConfDumper
12
+
13
+ from yaml import Node
14
+ from yaml.resolver import BaseResolver
15
+
16
+
17
+ def overwrite_omegaconf_dumper(mode: str = "|") -> None:
18
+ """
19
+ Overwrites the default string representation in OmegaConf's YAML dumper.
20
+
21
+ This function modifies the `OmegaConfDumper` to represent multi-line strings
22
+ using the specified style (`mode`). By default, it uses the `|` block style
23
+ for multi-line strings. Single-line strings remain unchanged.
24
+
25
+ Args:
26
+ mode (str, optional): The YAML style character for multi-line strings.
27
+ Defaults to "|".
28
+ """
29
+
30
+ def str_representer(dumper: OmegaConfDumper, data: str) -> Node:
31
+ return dumper.represent_scalar(
32
+ BaseResolver.DEFAULT_SCALAR_TAG, data, style=mode if len(data.splitlines()) > 1 else None
33
+ )
34
+
35
+ OmegaConfDumper.add_representer(str, str_representer)
36
+ OmegaConfDumper.str_representer_added = True
37
+
38
+
39
+ def resolve_inherit(config: DictConfig | ListConfig) -> DictConfig | ListConfig:
40
+ """Resolve _inherit_ in config
41
+
42
+ Merge the dict in ``_inherit_`` into a dict of the same hierarchy.
43
+ ``_inherit_`` is specified by omegaconf interpolation
44
+
45
+ Args:
46
+ config (DictConfig | ListConfig): The configuration loaded by load_config
47
+
48
+ Returns:
49
+ DictConfig | ListConfig: The configuration without ``_inherit_``
50
+ """
51
+ while isinstance(config, DictConfig) and "_inherit_" in config:
52
+ # resolve _inherit_
53
+ inherit_configs = config["_inherit_"]
54
+ if not isinstance(inherit_configs, ListConfig):
55
+ inherit_configs = [inherit_configs]
56
+
57
+ config.pop("_inherit_")
58
+
59
+ for inherit_config in inherit_configs:
60
+ if isinstance(inherit_config, DictConfig):
61
+ config = oc.merge(inherit_config, config)
62
+
63
+ # load child DictConfig to resolve child _inherit_
64
+ if isinstance(config, DictConfig):
65
+ dst_config_dict = copy.deepcopy(config)
66
+ for key in config:
67
+ dst_config_dict[key] = resolve_inherit(config[key])
68
+ config = dst_config_dict
69
+ elif isinstance(config, ListConfig):
70
+ dst_config_list = copy.deepcopy(config)
71
+ for key in range(len(config)):
72
+ dst_config_list[key] = resolve_inherit(config[key])
73
+ config = dst_config_list
74
+
75
+ return config
76
+
77
+
78
+ def load_config(
79
+ config_filename: str | Path,
80
+ parent_config: dict[str, Any] | DictConfig | ListConfig | None = None,
81
+ ) -> DictConfig | ListConfig:
82
+ """Load YAML configuration
83
+
84
+ When the user specifies ``_base_``, the specified YAML file is loaded as the base,
85
+ and the original configuration is merged with the base config.
86
+ If the configuration specified in ``_base_`` also contains ``_base_``, the process is handled recursively.
87
+
88
+ Additionally, if `bootstrap_config` is provided, it is merged with the final
89
+ configuration to ensure any default values or overrides are applied.
90
+
91
+ Args:
92
+ config (Path): Path to the configuration
93
+ parent_config (dict[str, Any] | DictConfig | ListConfig | None):
94
+ A configuration that is merged to the loaded configuration.
95
+ This is intended to define default config paths (e.g., working_directory) dynamically.
96
+
97
+ Returns:
98
+ merge_user_config (DictConfig): The merged configuration of the base config and the original config
99
+ user_config(DictConfig | ListConfig) : The configuration without ``_base_``
100
+
101
+ """
102
+
103
+ if not isinstance(config_filename, Path):
104
+ config_filename = Path(config_filename)
105
+
106
+ if not config_filename.is_absolute():
107
+ config_filename = Path.cwd() / config_filename
108
+
109
+ if parent_config is None:
110
+ parent_config = {}
111
+
112
+ config = oc.merge(oc.load(config_filename), parent_config)
113
+
114
+ if isinstance(config, DictConfig) and "_base_" in config:
115
+ # process _base_
116
+ base_paths = config["_base_"]
117
+ if not isinstance(base_paths, ListConfig):
118
+ base_paths = [base_paths]
119
+
120
+ config.pop("_base_")
121
+ for base_path in map(Path, base_paths):
122
+ if not base_path.is_absolute():
123
+ base_path = config_filename.parent / base_path
124
+
125
+ config = load_config(base_path, config)
126
+
127
+ return config
128
+
129
+
130
+ def print_config(config: ListConfig | DictConfig, line_length: int = 80) -> None:
131
+ """
132
+ Print the given configuration with syntax highlighting.
133
+
134
+ This function converts `pathlib.Path` objects to strings before printing,
135
+ ensuring that the output YAML format remains valid. It also highlights
136
+ configuration keys in yellow for better readability.
137
+
138
+ Args:
139
+ config (ListConfig | DictConfig): The configuration to print.
140
+ line_length (int, optional): The width of the separator line (default: 80).
141
+
142
+ """
143
+
144
+ config = pathlib2str_config(config) # https://github.com/omry/omegaconf/issues/82
145
+
146
+ print("=" * line_length)
147
+ for line in oc.to_yaml(config).splitlines():
148
+ print(re.sub(r"(\s*)(\w+):", rf"\1{Fore.YELLOW}\2{Fore.RESET}:", line, count=1))
149
+ print("=" * line_length)
150
+
151
+
152
+ def pathlib2str_config(config: ListConfig | DictConfig) -> ListConfig | DictConfig:
153
+ """
154
+ Convert `pathlib.Path` objects in the configuration to strings.
155
+
156
+ This function recursively traverses the configuration and replaces all `pathlib.Path`
157
+ objects with their string representations. This is useful for saving the configuration
158
+ in a YAML file, as YAML does not support `Path` objects.
159
+
160
+ Args:
161
+ config (ListConfig | DictConfig): The configuration to convert.
162
+
163
+ Returns:
164
+ ListConfig | DictConfig: The modified configuration with `Path` objects replaced by strings.
165
+
166
+ """
167
+
168
+ def _inner_fn(config: ListConfig | DictConfig) -> ListConfig | DictConfig:
169
+ if isinstance(config, ListConfig):
170
+ for ii in range(len(config)):
171
+ config[ii] = _inner_fn(config[ii])
172
+ elif isinstance(config, DictConfig):
173
+ for k, v in config.items():
174
+ if isinstance(v, ListConfig | DictConfig):
175
+ config[k] = _inner_fn(v)
176
+ elif isinstance(v, Path):
177
+ config[k] = str(v)
178
+
179
+ return config
180
+
181
+ return _inner_fn(deepcopy(config))