access-config-utils 0.1__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 (35) hide show
  1. access_config_utils-0.1/.github/workflows/cd.yml +72 -0
  2. access_config_utils-0.1/.github/workflows/ci.yml +90 -0
  3. access_config_utils-0.1/.gitignore +11 -0
  4. access_config_utils-0.1/.pre-commit-config.yaml +10 -0
  5. access_config_utils-0.1/.zenodo.json +26 -0
  6. access_config_utils-0.1/COPYRIGHT.txt +13 -0
  7. access_config_utils-0.1/LICENSE +201 -0
  8. access_config_utils-0.1/PKG-INFO +129 -0
  9. access_config_utils-0.1/README.md +107 -0
  10. access_config_utils-0.1/conda/environment.yml +10 -0
  11. access_config_utils-0.1/conda/meta.yaml +42 -0
  12. access_config_utils-0.1/pyproject.toml +46 -0
  13. access_config_utils-0.1/setup.cfg +4 -0
  14. access_config_utils-0.1/setup.py +5 -0
  15. access_config_utils-0.1/src/access/config/__init__.py +24 -0
  16. access_config_utils-0.1/src/access/config/config.lark +64 -0
  17. access_config_utils-0.1/src/access/config/esm1p6_layout_input.py +663 -0
  18. access_config_utils-0.1/src/access/config/fortran_nml.py +70 -0
  19. access_config_utils-0.1/src/access/config/layout_config.py +180 -0
  20. access_config_utils-0.1/src/access/config/mom6_input.py +64 -0
  21. access_config_utils-0.1/src/access/config/nuopc_config.py +130 -0
  22. access_config_utils-0.1/src/access/config/parser.py +440 -0
  23. access_config_utils-0.1/src/access/config/yaml_config.py +53 -0
  24. access_config_utils-0.1/src/access_config_utils.egg-info/PKG-INFO +129 -0
  25. access_config_utils-0.1/src/access_config_utils.egg-info/SOURCES.txt +33 -0
  26. access_config_utils-0.1/src/access_config_utils.egg-info/dependency_links.txt +1 -0
  27. access_config_utils-0.1/src/access_config_utils.egg-info/requires.txt +10 -0
  28. access_config_utils-0.1/src/access_config_utils.egg-info/top_level.txt +1 -0
  29. access_config_utils-0.1/tests/test_config.py +423 -0
  30. access_config_utils-0.1/tests/test_esm1p6_layout_input.py +387 -0
  31. access_config_utils-0.1/tests/test_fortran_nml.py +185 -0
  32. access_config_utils-0.1/tests/test_layout_config.py +159 -0
  33. access_config_utils-0.1/tests/test_mom6_input.py +136 -0
  34. access_config_utils-0.1/tests/test_nuopc_config.py +175 -0
  35. access_config_utils-0.1/tests/test_yaml_config.py +127 -0
@@ -0,0 +1,72 @@
1
+ name: CD
2
+ on:
3
+ push:
4
+ tags:
5
+ - 'v*'
6
+
7
+ env:
8
+ PY_VERSION: 3.12
9
+
10
+ jobs:
11
+ pypi-build:
12
+ name: Build package for PyPI
13
+ if: github.repository == 'ACCESS-NRI/access-config-utils' # exclude forks
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ env.PY_VERSION }}
21
+
22
+ - run: |
23
+ python3 -m pip install --upgrade build && python3 -m build
24
+
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: release
28
+ path: dist
29
+
30
+ pypi-publish:
31
+ # Split build and publish to restrict trusted publishing to just this workflow
32
+ needs: ['pypi-build']
33
+ name: Publish to PyPI.org
34
+ runs-on: ubuntu-latest
35
+ permissions:
36
+ # IMPORTANT: this permission is mandatory for trusted publishing
37
+ id-token: write
38
+ steps:
39
+ - uses: actions/download-artifact@v4
40
+ with:
41
+ name: release
42
+ path: dist
43
+
44
+ - name: Publish package distributions to PyPI
45
+ uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
46
+
47
+ conda:
48
+ name: Build with conda and upload
49
+ if: github.repository == 'ACCESS-NRI/access-config-utils' # exclude forks
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - name: Checkout source
53
+ uses: actions/checkout@v4
54
+
55
+ - name: Setup conda environment
56
+ uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
57
+ with:
58
+ miniconda-version: "latest"
59
+ python-version: ${{ env.PY_VERSION }}
60
+ environment-file: conda/environment.yml
61
+ auto-update-conda: false
62
+ auto-activate-base: false
63
+ show-channel-urls: true
64
+
65
+ - name: Build and upload conda package
66
+ uses: ACCESS-NRI/action-build-and-upload-conda-packages@v3.0.0
67
+ with:
68
+ meta_yaml_dir: conda
69
+ user: ${{ vars.ANACONDA_USER }}
70
+ label: main
71
+ token: ${{ secrets.ANACONDA_TOKEN }}
72
+
@@ -0,0 +1,90 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "main" ]
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ env:
16
+ PY_VERSION_BUILD: 3.12
17
+
18
+ jobs:
19
+ formatting:
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v3
23
+ - name: Code formatting
24
+ uses: astral-sh/ruff-action@v3
25
+ with:
26
+ args: "format --check --diff"
27
+
28
+ pypa-build:
29
+ name: PyPA build
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: ${{ env.PY_VERSION_BUILD }}
37
+ cache: 'pip' # caching pip dependencies
38
+
39
+ - run: |
40
+ python3 -m pip install --upgrade build && python3 -m build
41
+
42
+ conda-build:
43
+ name: Conda Build
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+
48
+ - name: Setup conda environment
49
+ uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0
50
+ with:
51
+ miniconda-version: "latest"
52
+ python-version: ${{ env.PY_VERSION_BUILD }}
53
+ environment-file: conda/environment.yml
54
+ auto-update-conda: false
55
+ auto-activate-base: false
56
+ show-channel-urls: true
57
+
58
+ - name: Build conda package
59
+ uses: ACCESS-NRI/action-build-and-upload-conda-packages@v3.0.0
60
+ with:
61
+ meta_yaml_dir: conda
62
+ label: main
63
+ upload: false
64
+
65
+ build:
66
+ needs: formatting
67
+ runs-on: ubuntu-latest
68
+ strategy:
69
+ matrix:
70
+ python-version: ['3.11', '3.12', '3.13']
71
+
72
+ steps:
73
+ - uses: actions/checkout@v3
74
+ - name: Set up Python ${{ matrix.python-version }}
75
+ uses: actions/setup-python@v3
76
+ with:
77
+ python-version: ${{ matrix.python-version }}
78
+ - name: Install dependencies
79
+ run: |
80
+ python -m pip install --upgrade pip
81
+ pip install '.[devel,test]'
82
+ - name: Lint with ruff
83
+ uses: astral-sh/ruff-action@v3
84
+ - name: Test with pytest
85
+ run: |
86
+ python -m pytest
87
+ - name: Upload coverage reports to Codecov with GitHub Action
88
+ uses: codecov/codecov-action@v5
89
+ with:
90
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,11 @@
1
+ *.pyc
2
+ /__pycache__
3
+ /build
4
+ /dist
5
+ _version.py
6
+ .coverage
7
+ coverage.xml
8
+ *.egg-info
9
+ .ipynb_checkpoints
10
+ .vscode
11
+ .idea
@@ -0,0 +1,10 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ # Ruff version.
4
+ rev: v0.13.2
5
+ hooks:
6
+ # Run the linter.
7
+ - id: ruff-check
8
+ args: [ --fix ]
9
+ # Run the formatter.
10
+ - id: ruff-format
@@ -0,0 +1,26 @@
1
+ {
2
+ "creators": [
3
+ {
4
+ "orcid": "0000-0003-3891-5444",
5
+ "affiliation": "ACCESS-NRI",
6
+ "name": "Beucher, Romain"
7
+ },
8
+ {
9
+ "affiliation": "ACCESS-NRI",
10
+ "name": "Carouge, Claire"
11
+ }
12
+ ],
13
+
14
+ "license": "Apache-2.0",
15
+
16
+ "title": "ACCESS-NRI Template",
17
+ "decription": "Template repository for ACCESS-NRI, test",
18
+
19
+ "keywords": ["Climate", "Science", "ACCESS-NRI", "NCI"],
20
+
21
+ "communities": [
22
+ {"identifier": "access-nri"}
23
+ ],
24
+
25
+ "grants": [{"id":""}]
26
+ }
@@ -0,0 +1,13 @@
1
+ Copyright 2022 ACCESS-NRI
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: access-config-utils
3
+ Version: 0.1
4
+ Summary: Utilities to work with configurations for the ACCESS climate models.
5
+ Author-email: Micael Oliveira <micael.oliveira@anu.edu.au>
6
+ Keywords: configurations,parser,access
7
+ Classifier: License :: OSI Approved :: Apache Software License
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Utilities
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: lark
14
+ Requires-Dist: ruamel.yaml
15
+ Provides-Extra: devel
16
+ Requires-Dist: ruff; extra == "devel"
17
+ Requires-Dist: pre-commit; extra == "devel"
18
+ Provides-Extra: test
19
+ Requires-Dist: pytest; extra == "test"
20
+ Requires-Dist: pytest-cov; extra == "test"
21
+ Dynamic: license-file
22
+
23
+ # access-config-utils
24
+
25
+ ![CI](https://github.com/ACCESS-NRI/access-config-utils/actions/workflows/ci.yml/badge.svg) [![codecov](https://codecov.io/github/ACCESS-NRI/access-config-utils/graph/badge.svg?token=KtmrCtSyMv)](https://codecov.io/github/ACCESS-NRI/access-config-utils) [![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](https://opensource.org/license/apache-2-0) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
26
+
27
+ ## About
28
+
29
+ A Python package providing various utilities to work with configurations for the models developed at [ACCESS-NRI](https://github.com/ACCESS-NRI).
30
+
31
+ ## Key Features
32
+
33
+ Parsers:
34
+ - Various parsers for configuration files used across ACCESS-NRI models
35
+ - Support for round-trip parsing, preserving comments and formatting
36
+ - Simple API
37
+
38
+ ## Documentation
39
+
40
+ Coming soon.
41
+
42
+ ## Installation
43
+
44
+ ### Using pip
45
+
46
+ You can install the latest release directly from PyPI:
47
+ ```shell
48
+ pip install access-config-utils
49
+ ```
50
+
51
+ ### From source
52
+
53
+ If you prefer to install from source:
54
+ ```shell
55
+ git clone https://github.com/ACCESS-NRI/access-config-utils.git
56
+ cd access-config-utils
57
+ pip install .
58
+ ```
59
+
60
+ ## Usage
61
+
62
+ ### Configuration files parsers
63
+
64
+ Here is a simple example of how to parse a text and modify its contents.
65
+
66
+ To parse some text, one just needs to call the `parse` function of the appropriate parser:
67
+ ```python
68
+ from access.config import FortranNMLParser
69
+
70
+ text = '''&data_nml
71
+ parameterA = 1
72
+ parameterB = 'abc'
73
+ /'''
74
+
75
+ config = FortranNMLParser().parse(text)
76
+ print(config)
77
+ ```
78
+ ```python
79
+ &data_nml
80
+ parameterA = 1
81
+ parameterB = 'abc'
82
+ /
83
+ ```
84
+
85
+ The parsed content can then be modified just like any Python dict:
86
+ ```python
87
+ config["data_nml"]["parameterA"] = 2
88
+ print(config)
89
+ ```
90
+ ```python
91
+ &data_nml
92
+ parameterA = 2
93
+ parameterB = 'abc'
94
+ /
95
+ ```
96
+
97
+ ## Development installation
98
+
99
+ If you intend to contribute or modify the package, it is recommended to work inside a virtual environment.
100
+
101
+ 1. Create and activate a virtual environment
102
+ ```shell
103
+ # Create a virtual environment
104
+ python3 -m venv .venv
105
+
106
+ # Activate the virtual environment
107
+ source .venv/bin/activate
108
+ ```
109
+
110
+ 2. Install in editable mode with development and test dependencies
111
+ ```shell
112
+ pip install -e ".[devel,test]"
113
+ ```
114
+ This will install the package in editable mode, meaning changes to the source code are reflected immediately without reinstallation. Development dependencies such as testing tools will also be installed.
115
+
116
+ 3. Run the test suite
117
+ ```shell
118
+ pytest
119
+ ```
120
+
121
+ ## Contributing
122
+
123
+ Contributions are welcome! Please open an issue or submit a pull request if you’d like to add features, fix bugs, or improve documentation.
124
+
125
+ For significant contributions, we recommend discussing proposed changes in an issue before opening a pull request.
126
+
127
+ ## License
128
+
129
+ This project is licensed under the Apache 2.0 License.
@@ -0,0 +1,107 @@
1
+ # access-config-utils
2
+
3
+ ![CI](https://github.com/ACCESS-NRI/access-config-utils/actions/workflows/ci.yml/badge.svg) [![codecov](https://codecov.io/github/ACCESS-NRI/access-config-utils/graph/badge.svg?token=KtmrCtSyMv)](https://codecov.io/github/ACCESS-NRI/access-config-utils) [![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](https://opensource.org/license/apache-2-0) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
4
+
5
+ ## About
6
+
7
+ A Python package providing various utilities to work with configurations for the models developed at [ACCESS-NRI](https://github.com/ACCESS-NRI).
8
+
9
+ ## Key Features
10
+
11
+ Parsers:
12
+ - Various parsers for configuration files used across ACCESS-NRI models
13
+ - Support for round-trip parsing, preserving comments and formatting
14
+ - Simple API
15
+
16
+ ## Documentation
17
+
18
+ Coming soon.
19
+
20
+ ## Installation
21
+
22
+ ### Using pip
23
+
24
+ You can install the latest release directly from PyPI:
25
+ ```shell
26
+ pip install access-config-utils
27
+ ```
28
+
29
+ ### From source
30
+
31
+ If you prefer to install from source:
32
+ ```shell
33
+ git clone https://github.com/ACCESS-NRI/access-config-utils.git
34
+ cd access-config-utils
35
+ pip install .
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Configuration files parsers
41
+
42
+ Here is a simple example of how to parse a text and modify its contents.
43
+
44
+ To parse some text, one just needs to call the `parse` function of the appropriate parser:
45
+ ```python
46
+ from access.config import FortranNMLParser
47
+
48
+ text = '''&data_nml
49
+ parameterA = 1
50
+ parameterB = 'abc'
51
+ /'''
52
+
53
+ config = FortranNMLParser().parse(text)
54
+ print(config)
55
+ ```
56
+ ```python
57
+ &data_nml
58
+ parameterA = 1
59
+ parameterB = 'abc'
60
+ /
61
+ ```
62
+
63
+ The parsed content can then be modified just like any Python dict:
64
+ ```python
65
+ config["data_nml"]["parameterA"] = 2
66
+ print(config)
67
+ ```
68
+ ```python
69
+ &data_nml
70
+ parameterA = 2
71
+ parameterB = 'abc'
72
+ /
73
+ ```
74
+
75
+ ## Development installation
76
+
77
+ If you intend to contribute or modify the package, it is recommended to work inside a virtual environment.
78
+
79
+ 1. Create and activate a virtual environment
80
+ ```shell
81
+ # Create a virtual environment
82
+ python3 -m venv .venv
83
+
84
+ # Activate the virtual environment
85
+ source .venv/bin/activate
86
+ ```
87
+
88
+ 2. Install in editable mode with development and test dependencies
89
+ ```shell
90
+ pip install -e ".[devel,test]"
91
+ ```
92
+ This will install the package in editable mode, meaning changes to the source code are reflected immediately without reinstallation. Development dependencies such as testing tools will also be installed.
93
+
94
+ 3. Run the test suite
95
+ ```shell
96
+ pytest
97
+ ```
98
+
99
+ ## Contributing
100
+
101
+ Contributions are welcome! Please open an issue or submit a pull request if you’d like to add features, fix bugs, or improve documentation.
102
+
103
+ For significant contributions, we recommend discussing proposed changes in an issue before opening a pull request.
104
+
105
+ ## License
106
+
107
+ This project is licensed under the Apache 2.0 License.
@@ -0,0 +1,10 @@
1
+ channels:
2
+ - conda-forge
3
+ - accessnri
4
+ - default
5
+
6
+ dependencies:
7
+ - anaconda-client
8
+ - conda-build
9
+ - conda-verify
10
+ - setuptools_scm