Skip to content

Commit 2eee3ca

Browse files
committed
Merge branch 'main' of https://github.com/CCPBioSim/CodeEntropy into 43-version-1-documentation
2 parents 334e33b + 19118a4 commit 2eee3ca

7 files changed

Lines changed: 206 additions & 84 deletions

File tree

.github/workflows/project-ci.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ on:
99

1010
jobs:
1111
tests:
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-24.04
1313
timeout-minutes: 30
1414
strategy:
1515
matrix:
1616
python-version: ["3.11", "3.12", "3.13"]
1717
name: Run tests
1818
steps:
1919
- name: Checkout repo
20-
uses: actions/checkout@v5
20+
uses: actions/checkout@v5.0.0
2121

2222
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v5
23+
uses: actions/setup-python@v5.6.0
2424
with:
2525
python-version: ${{ matrix.python-version }}
2626

@@ -36,14 +36,14 @@ jobs:
3636
github-token: ${{ secrets.GITHUB_TOKEN }}
3737

3838
docs:
39-
runs-on: ubuntu-latest
39+
runs-on: ubuntu-24.04
4040
timeout-minutes: 15
4141
steps:
42-
- uses: actions/checkout@v5
43-
- name: Set up Python 3.12
44-
uses: actions/setup-python@v5
42+
- uses: actions/checkout@v5.0.0
43+
- name: Set up Python 3.13
44+
uses: actions/setup-python@v5.6.0
4545
with:
46-
python-version: 3.12
46+
python-version: 3.13
4747
- name: Install python dependencies
4848
run: |
4949
pip install --upgrade pip
@@ -52,14 +52,14 @@ jobs:
5252
run: cd docs && make
5353

5454
pre-commit:
55-
runs-on: ubuntu-latest
55+
runs-on: ubuntu-24.04
5656
timeout-minutes: 15
5757
steps:
58-
- uses: actions/checkout@v5
59-
- name: Set up Python 3.11
60-
uses: actions/setup-python@v5
58+
- uses: actions/checkout@v5.0.0
59+
- name: Set up Python 3.13
60+
uses: actions/setup-python@v5.6.0
6161
with:
62-
python-version: 3.11
62+
python-version: 3.13
6363
- name: Install python dependencies
6464
run: |
6565
pip install --upgrade pip
@@ -71,7 +71,7 @@ jobs:
7171
7272
mdanalysis-compatibility:
7373
if: github.event_name == 'schedule'
74-
runs-on: ubuntu-latest
74+
runs-on: ubuntu-24.04
7575
timeout-minutes: 15
7676
strategy:
7777
matrix:
@@ -80,10 +80,10 @@ jobs:
8080
name: MDAnalysis Compatibility Tests
8181
steps:
8282
- name: Checkout repo
83-
uses: actions/checkout@v5
83+
uses: actions/checkout@v5.0.0
8484

8585
- name: Set up Python ${{ matrix.python-version }}
86-
uses: actions/setup-python@v5
86+
uses: actions/setup-python@v5.6.0
8787
with:
8888
python-version: ${{ matrix.python-version }}
8989

@@ -112,4 +112,4 @@ jobs:
112112
with:
113113
filename: .github/workflows/mdanalysis-compatibility-failure.md
114114
update_existing: true
115-
search_existing: open
115+
search_existing: open

.github/workflows/publish-on-pypi.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yaml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
required: true
8+
default: 'x.y.z'
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
checks:
16+
name: Version check
17+
runs-on: ubuntu-24.04
18+
steps:
19+
- name: Checkout repository
20+
id: repo
21+
uses: actions/checkout@v5.0.0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5.6.0
25+
with:
26+
python-version: 3.13
27+
28+
- name: Get latest release from pip
29+
id: latestreleased
30+
run: |
31+
PREVIOUS_VERSION=$(python -m pip index versions CodeEntropy | grep "CodeEntropy" | cut -d "(" -f2 | cut -d ")" -f1)
32+
echo "pip_tag=$PREVIOUS_VERSION" >> "$GITHUB_OUTPUT"
33+
echo $PREVIOUS_VERSION
34+
35+
- name: version comparison
36+
id: compare
37+
run: |
38+
pip3 install semver
39+
output=$(pysemver compare ${{ steps.latestreleased.outputs.pip_tag }} ${{ github.event.inputs.version }})
40+
if [ $output -ge 0 ]; then exit 1; fi
41+
42+
version:
43+
name: prepare ${{ github.event.inputs.version }}
44+
needs: checks
45+
runs-on: ubuntu-24.04
46+
steps:
47+
48+
- name: checkout
49+
uses: actions/checkout@v5.0.0
50+
51+
- name: Change version in repo
52+
run: sed -i "s/__version__ =.*/__version__ = \"${{ github.event.inputs.version }}\"/g" CodeEntropy/__init__.py
53+
54+
- name: send PR
55+
id: pr_id
56+
uses: peter-evans/create-pull-request@v7.0.8
57+
with:
58+
commit-message: Update version to ${{ github.event.inputs.version }}
59+
branch: version-update
60+
title: "Update to version ${{ github.event.inputs.version }}"
61+
body: |
62+
Update version
63+
- Update the __init__.py with new release
64+
- Auto-generated by [CI]
65+
base: main
66+
signoff: false
67+
draft: false
68+
69+
- name: merge PR
70+
run: gh pr merge --merge --delete-branch --auto "${{ steps.pr_id.outputs.pull-request-number }}"
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
tag:
75+
name: tag release
76+
needs: version
77+
runs-on: ubuntu-24.04
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/checkout@v5.0.0
81+
with:
82+
ref: main
83+
84+
- name: tag v${{ github.event.inputs.version }}
85+
run: |
86+
git config user.name github-actions
87+
git config user.email github-actions@github.com
88+
git tag ${{ github.event.inputs.version }}
89+
git push origin tag ${{ github.event.inputs.version }}
90+
91+
release:
92+
name: make github release
93+
needs: tag
94+
runs-on: ubuntu-24.04
95+
steps:
96+
97+
- name: create release
98+
uses: softprops/action-gh-release@v2.3.2
99+
with:
100+
name: v${{ github.event.inputs.version }}
101+
generate_release_notes: true
102+
tag_name: ${{ github.event.inputs.version }}
103+
104+
pypi:
105+
name: make pypi release
106+
needs: [tag, release]
107+
runs-on: ubuntu-24.04
108+
steps:
109+
110+
- name: checkout
111+
uses: actions/checkout@v5.0.0
112+
with:
113+
ref: main
114+
115+
- name: Set up Python
116+
uses: actions/setup-python@v5.6.0
117+
with:
118+
python-version: 3.13
119+
120+
- name: Install flit
121+
run: |
122+
python -m pip install --upgrade pip
123+
python -m pip install flit~=3.9
124+
125+
- name: Build and publish
126+
run: |
127+
flit publish
128+
env:
129+
FLIT_USERNAME: __token__
130+
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
131+

CodeEntropy/config/arg_config_manager.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import glob
23
import logging
34
import os
45

@@ -77,16 +78,26 @@ def __init__(self):
7778
self.arg_map = arg_map
7879

7980
def load_config(self, file_path):
80-
"""Load YAML configuration file."""
81-
if not os.path.exists(file_path):
82-
raise FileNotFoundError(f"Configuration file '{file_path}' not found.")
81+
"""Load YAML configuration file from the given directory."""
82+
yaml_files = glob.glob(os.path.join(file_path, "*.yaml"))
8383

84-
with open(file_path, "r") as file:
85-
config = yaml.safe_load(file)
86-
87-
# If YAML content is empty, return an empty dictionary
88-
if config is None:
89-
config = {}
84+
if not yaml_files:
85+
logger.warning(
86+
f"No YAML configuration files found in directory: {file_path}. "
87+
"Expected a file with extension '.yaml'. "
88+
"Proceeding with default configuration: {'run1': {}}."
89+
)
90+
return {"run1": {}}
91+
92+
try:
93+
with open(yaml_files[0], "r") as file:
94+
config = yaml.safe_load(file)
95+
logger.info(f"Loaded configuration from: {yaml_files[0]}")
96+
if config is None:
97+
config = {"run1": {}}
98+
except Exception as e:
99+
logger.error(f"Failed to load config file: {e}")
100+
config = {"run1": {}}
90101

91102
return config
92103

CodeEntropy/run.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ def run_entropy_workflow(self):
9595
try:
9696
logger = self._logging_config.setup_logging()
9797

98-
config = self._config_manager.load_config("config.yaml")
99-
if config is None:
100-
raise ValueError(
101-
"No configuration file found, and no CLI arguments were provided."
102-
)
98+
current_directory = os.getcwd()
10399

100+
config = self._config_manager.load_config(current_directory)
104101
parser = self._config_manager.setup_argparse()
105102
args, _ = parser.parse_known_args()
106103
args.output_file = os.path.join(self.folder, args.output_file)

config.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)