mirror of
https://github.com/OpenFreeEnergy/openfe.git
synced 2026-06-04 14:14:22 +08:00
Merge branch 'main' into feat/track-test-test-cov
This commit is contained in:
60
.github/workflows/gen-lock-file.yaml
vendored
60
.github/workflows/gen-lock-file.yaml
vendored
@@ -8,15 +8,10 @@ defaults:
|
||||
shell: bash -leo pipefail {0}
|
||||
|
||||
jobs:
|
||||
create-conda-lock-file:
|
||||
create-conda-lock-file-and-test-linux:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
steps:
|
||||
- name: Install conda-lock with Micromamba
|
||||
uses: mamba-org/setup-micromamba@v2
|
||||
with:
|
||||
@@ -24,11 +19,16 @@ jobs:
|
||||
create-args: >-
|
||||
conda-lock
|
||||
|
||||
- name: Get Latest Version
|
||||
# This saves me some time since we only need the latest tag
|
||||
- name: Get latest tag
|
||||
id: latest-version
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||
# slice off the v, ie v0.7.2 -> 0.7.2
|
||||
LATEST_TAG=$(curl -s -H "Authorization: token $GH_TOKEN" \
|
||||
https://api.github.com/repos/$REPO/tags \
|
||||
| jq -r '.[0].name')
|
||||
VERSION=${LATEST_TAG:1}
|
||||
echo $VERSION
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
@@ -52,15 +52,49 @@ jobs:
|
||||
|
||||
- name: Generate lock files
|
||||
run: |
|
||||
conda lock --with-cuda 11.8 -f environment-to-lock.yaml openfe-conda-lock.yml
|
||||
conda lock --with-cuda 11.8 -f environment-to-lock.yaml --lockfile openfe-conda-lock.yml
|
||||
cp openfe-conda-lock.yml openfe-${{ steps.latest-version.outputs.VERSION }}-conda-lock.yml
|
||||
|
||||
- name: Upload openfe forge to release
|
||||
- name: Test lock file (linux)
|
||||
run: |
|
||||
conda-lock install -p /home/runner/micromamba/envs/lf-test openfe-conda-lock.yml
|
||||
micromamba activate /home/runner/micromamba/envs/lf-test
|
||||
openfe test
|
||||
|
||||
- name: Upload file as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: conda-lock-files
|
||||
path: "*conda-lock.yml"
|
||||
|
||||
test-osx-lock-file:
|
||||
needs: create-conda-lock-file-and-test-linux
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: conda-lock-files
|
||||
|
||||
- name: Install conda-lock with Micromamba
|
||||
uses: mamba-org/setup-micromamba@v2
|
||||
with:
|
||||
environment-name: conda-lock
|
||||
create-args: >-
|
||||
conda-lock
|
||||
|
||||
- name: Test lock file (osx)
|
||||
run: |
|
||||
conda-lock install -p /Users/runner/micromamba/envs/lf-test openfe-conda-lock.yml
|
||||
micromamba activate /Users/runner/micromamba/envs/lf-test
|
||||
openfe test
|
||||
|
||||
- name: Upload lock files to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: "*conda-lock.yml"
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
file_glob: true
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
@@ -3,7 +3,7 @@ channels:
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- cinnabar ~=0.4.0
|
||||
- click <8.2.0
|
||||
- click >=8.2.0
|
||||
- coverage
|
||||
- duecredit<0.10
|
||||
- kartograf>=1.0.0
|
||||
|
||||
@@ -8,7 +8,7 @@ class TestHyphenAwareChoice:
|
||||
])
|
||||
def test_init(self, value):
|
||||
ch = HyphenAwareChoice([value])
|
||||
assert ch.choices == ["foo-bar-baz"]
|
||||
assert ch.choices == ("foo-bar-baz",)
|
||||
|
||||
@pytest.mark.parametrize('value', [
|
||||
"foo_bar_baz", "foo_bar-baz", "foo-bar_baz", "foo-bar-baz"
|
||||
|
||||
@@ -128,7 +128,7 @@ class TestResultLoading:
|
||||
assert "Missing ligand names and/or simulation type. Skipping" in captured.err
|
||||
|
||||
def test_no_results_found():
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, "not_a_file.txt")
|
||||
assert cli_result.exit_code == 1
|
||||
assert "No results JSON files found" in str(cli_result.stderr)
|
||||
@@ -239,11 +239,11 @@ class TestGatherCMET:
|
||||
def test_cmet_full_results(self, cmet_result_dir, report, file_regression):
|
||||
results = [str(cmet_result_dir / f'results_{i}') for i in range(3)]
|
||||
args = ["--report", report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args + ['--tsv'])
|
||||
|
||||
assert_click_success(cli_result)
|
||||
file_regression.check(cli_result.output, extension='.tsv')
|
||||
file_regression.check(cli_result.stdout, extension='.tsv')
|
||||
|
||||
# TODO: add --allow-partial behavior checks
|
||||
@pytest.mark.parametrize('report', ["dg", "ddg", "raw"])
|
||||
@@ -251,38 +251,38 @@ class TestGatherCMET:
|
||||
"""Missing one complex replicate from one leg."""
|
||||
results = [str(cmet_result_dir / d) for d in ['results_0_partial', 'results_1', "results_2"]]
|
||||
args = ["--report", report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args + ['--tsv'])
|
||||
|
||||
assert_click_success(cli_result)
|
||||
file_regression.check(cli_result.output, extension='.tsv')
|
||||
file_regression.check(cli_result.stdout, extension='.tsv')
|
||||
|
||||
@pytest.mark.parametrize('report', ["dg", "ddg", "raw"])
|
||||
def test_cmet_missing_edge(self, cmet_result_dir, report,file_regression):
|
||||
results = [str(cmet_result_dir / f'results_{i}_remove_edge') for i in range(3)]
|
||||
args = ["--report", report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args + ['--tsv'])
|
||||
file_regression.check(cli_result.output, extension='.tsv')
|
||||
file_regression.check(cli_result.stdout, extension='.tsv')
|
||||
|
||||
assert_click_success(cli_result)
|
||||
file_regression.check(cli_result.output, extension='.tsv')
|
||||
file_regression.check(cli_result.stdout, extension='.tsv')
|
||||
|
||||
@pytest.mark.parametrize('report', ["ddg", "raw"])
|
||||
def test_cmet_failed_edge(self, cmet_result_dir, report, file_regression):
|
||||
results = [str(cmet_result_dir / f'results_{i}_failed_edge') for i in range(3)]
|
||||
args = ["--report", report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args + ['--tsv'])
|
||||
|
||||
assert_click_success(cli_result)
|
||||
file_regression.check(cli_result.output, extension=".tsv")
|
||||
file_regression.check(cli_result.stdout, extension=".tsv")
|
||||
|
||||
@pytest.mark.parametrize("allow_partial", [True, False])
|
||||
def test_cmet_too_few_edges_error(self, cmet_result_dir, allow_partial):
|
||||
results = [str(cmet_result_dir / f"results_{i}_failed_edge") for i in range(3)]
|
||||
args = ["--report", "dg"]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
if allow_partial:
|
||||
args += ['--allow-partial']
|
||||
|
||||
@@ -298,41 +298,41 @@ class TestGatherCMET:
|
||||
"""Missing one complex replicate from one leg."""
|
||||
results = glob.glob(f"{cmet_result_dir}/results_*/*solvent*", recursive=True)
|
||||
args = ["--report", report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args + ["-o", "-"])
|
||||
|
||||
cli_result.exit_code == 1
|
||||
file_regression.check(cli_result.output, extension='.tsv')
|
||||
file_regression.check(cli_result.stdout, extension='.tsv')
|
||||
|
||||
@pytest.mark.parametrize('report', ["ddg"])
|
||||
def test_cmet_missing_all_complex_legs_allow_partial(self, cmet_result_dir, report, file_regression):
|
||||
"""Missing one complex replicate from one leg."""
|
||||
results = glob.glob(f"{cmet_result_dir}/results_*/*solvent*", recursive=True)
|
||||
args = ["--report", report, "--allow-partial"]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args + ['--tsv'])
|
||||
|
||||
assert_click_success(cli_result)
|
||||
file_regression.check(cli_result.output, extension='.tsv')
|
||||
file_regression.check(cli_result.stdout, extension='.tsv')
|
||||
|
||||
@pytest.mark.parametrize('report', ["dg", "ddg", "raw"])
|
||||
def test_pretty_print(self, cmet_result_dir, report, file_regression):
|
||||
results = [str(cmet_result_dir / f'results_{i}') for i in range(3)]
|
||||
args = ["--report", report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
cli_result = runner.invoke(gather, results + args)
|
||||
assert_click_success(cli_result)
|
||||
# TODO: figure out how to mock terminal size, since it affects the table wrapping
|
||||
# file_regression.check(cli_result.output, extension='.txt')
|
||||
# file_regression.check(cli_result.stdout, extension='.txt')
|
||||
|
||||
def test_write_to_file(self, cmet_result_dir):
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
with runner.isolated_filesystem():
|
||||
results = [str(cmet_result_dir / f'results_{i}') for i in range(3)]
|
||||
fname = "output.tsv"
|
||||
args = ["--report", "raw", "-o", fname]
|
||||
cli_result = runner.invoke(gather, results + args)
|
||||
assert "writing raw output to 'output.tsv'" in cli_result.output
|
||||
assert "writing raw output to 'output.tsv'" in cli_result.stdout
|
||||
assert pathlib.Path(fname).is_file()
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ def test_rbfe_gather(rbfe_result_dir, dataset, report, input_mode):
|
||||
"ddg": _RBFE_EXPECTED_DDG,
|
||||
"raw": _RBFE_EXPECTED_RAW,
|
||||
}[report]
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
|
||||
if report:
|
||||
args = ["--report", report]
|
||||
@@ -372,7 +372,7 @@ def test_rbfe_gather(rbfe_result_dir, dataset, report, input_mode):
|
||||
def test_rbfe_gather_single_repeats_dg_error(rbfe_result_dir):
|
||||
"""A single repeat is insufficient for a dg calculation - should fail cleanly."""
|
||||
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
results = rbfe_result_dir("rbfe_results_parallel_repeats")
|
||||
args = ['report','dg']
|
||||
cli_result = runner.invoke(gather, [f"{results}/replicate_0"] + args + ['--tsv'])
|
||||
@@ -394,7 +394,7 @@ class TestRBFEGatherFailedEdges:
|
||||
return results_filtered
|
||||
|
||||
def test_missing_leg_error(self, results_paths_serial_missing_legs: str):
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(gather, results_paths_serial_missing_legs + ["--report", "dg"])
|
||||
|
||||
assert result.exit_code == 1
|
||||
@@ -405,7 +405,7 @@ class TestRBFEGatherFailedEdges:
|
||||
|
||||
|
||||
def test_missing_leg_allow_partial_disconnected(self, results_paths_serial_missing_legs: str):
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
with pytest.warns():
|
||||
args = ["--report", "dg", "--allow-partial"]
|
||||
result = runner.invoke(gather, results_paths_serial_missing_legs + args + ['--tsv'])
|
||||
@@ -414,7 +414,7 @@ class TestRBFEGatherFailedEdges:
|
||||
|
||||
|
||||
def test_missing_leg_allow_partial_(self, results_paths_serial_missing_legs: str):
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
# we *dont* want the suggestion to use --allow-partial if the user already used it!
|
||||
with pytest.warns(match='[^using the \-\-allow\-partial]'):
|
||||
args = ["--report", "ddg", "--allow-partial"]
|
||||
|
||||
Reference in New Issue
Block a user