Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase CI sensitivity by testing both lowest-direct and highest dependency resolution strategy #640

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
14 changes: 10 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,20 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
version:
- { python: "3.9", resolution: highest, extras: "tests,strict" }
- { python: "3.10", resolution: lowest-direct, extras: "tests" }
- { python: "3.11", resolution: highest, extras: tests }
# python 3.12 CI failing due to maggma incompatible, see
# https://github.com/materialsproject/jobflow/pull/640#issuecomment-2209055692
# - { python: "3.12", resolution: lowest-direct, extras: tests }

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.version.python }}
cache: pip
cache-dependency-path: pyproject.toml

Expand All @@ -52,13 +58,13 @@ jobs:
- name: Install dependencies
run: |
pip install uv
uv pip install .[strict,tests] --system
uv pip install '.[${{ matrix.version.extras }}]' --system --resolution=${{ matrix.version.resolution }}

- name: Test
run: pytest --cov=jobflow --cov-report=xml

- uses: codecov/codecov-action@v1
if: matrix.python-version == '3.11' && github.repository == 'materialsproject/jobflow'
if: matrix.version.python == '3.11' && github.repository == 'materialsproject/jobflow'
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
exclude: "^src/atomate2/vasp/schemas/calc_types/"
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.2
rev: v0.5.4
hooks:
- id: ruff
args: [--fix]
Expand All @@ -17,7 +17,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
Expand All @@ -43,7 +43,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
rev: v1.11.0
hooks:
- id: mypy
files: ^src/
Expand All @@ -52,7 +52,7 @@ repos:
- types-pkg_resources==0.1.2
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
stages: [commit, commit-msg]
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ classifiers = [
]
requires-python = ">=3.9"
dependencies = [
"PyYAML",
"maggma>=0.57.0",
"PyYAML>=6.0.1",
"maggma>=0.69.0",
"monty>=2023.9.25",
"networkx",
"networkx>=3.2.1",
"pydantic-settings>=2.0.3",
"pydantic>=2.0.1",
"pydash",
"pydantic>=2.4",
"pydash>=8.0.1",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/jobflow/core/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def recursive_call(

if isinstance(class_filter, Maker):
# Maker instance supplied rather than a Maker class
class_filter = class_filter.__class__
class_filter = class_filter.__class__ # type: ignore[assignment]

def _filter(nested_obj: Maker):
# Filter the Maker object
Expand Down
7 changes: 5 additions & 2 deletions tests/core/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ def test_graph():


def test_draw_graph():
pytest.importorskip("matplotlib")

from jobflow import Flow, JobOrder

# test unconnected graph
Expand Down Expand Up @@ -383,8 +385,9 @@ def test_draw_graph():
assert flow.draw_graph()


@pytest.mark.usefixtures("no_pydot")
def test_draw_graph_nopydot():
def test_draw_graph_nopydot(no_pydot):
pytest.importorskip("matplotlib")

from jobflow import Flow, JobOrder

# test unconnected graph
Expand Down
2 changes: 2 additions & 0 deletions tests/core/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_basic(memory_store):


def test_additional(memory_store):
pytest.importorskip("moto")

from copy import deepcopy

import boto3
Expand Down
14 changes: 8 additions & 6 deletions tests/managers/test_fireworks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

pytest.importorskip("fireworks")


def test_flow_to_workflow(
memory_jobstore, simple_job, simple_flow, connected_flow, nested_flow
Expand All @@ -13,7 +15,7 @@ def test_flow_to_workflow(
flow = simple_job()
wf = flow_to_workflow(flow, memory_jobstore)

assert type(wf) == Workflow
assert type(wf) is Workflow
assert wf.name == "Flow"
assert len(wf.fws) == 1
assert wf.fws[0].name == "func"
Expand All @@ -22,7 +24,7 @@ def test_flow_to_workflow(
flow = simple_job()
wf = flow_to_workflow(flow, name="custom_name")

assert type(wf) == Workflow
assert type(wf) is Workflow
assert wf.name == "custom_name"
assert len(wf.fws) == 1
assert wf.fws[0].name == "func"
Expand All @@ -31,7 +33,7 @@ def test_flow_to_workflow(
flow = simple_flow()
wf = flow_to_workflow(flow, memory_jobstore)

assert type(wf) == Workflow
assert type(wf) is Workflow
assert wf.name == "Flow"
assert len(wf.fws) == 1
assert wf.fws[0].name == "func"
Expand All @@ -40,7 +42,7 @@ def test_flow_to_workflow(
flow = connected_flow()
wf = flow_to_workflow(flow, memory_jobstore)

assert type(wf) == Workflow
assert type(wf) is Workflow
assert wf.name == "Connected Flow"
assert len(wf.fws) == 2
assert wf.fws[0].name == "func"
Expand Down Expand Up @@ -81,15 +83,15 @@ def test_job_to_firework(
job = simple_job()
fw = job_to_firework(job, memory_jobstore)

assert type(fw) == Firework
assert type(fw) is Firework
assert fw.name == "func"

job2 = simple_job()
fw = job_to_firework(
job2, memory_jobstore, parents=[job.uuid], parent_mapping={job.uuid: 1}
)

assert type(fw) == Firework
assert type(fw) is Firework
assert fw.name == "func"

with pytest.raises(ValueError, match="Both or neither of"):
Expand Down
12 changes: 8 additions & 4 deletions tests/utils/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def test_itergraph():


def test_draw_graph():
pytest.importorskip("matplotlib")

from networkx import DiGraph, planar_layout

from jobflow.utils.graph import draw_graph
Expand All @@ -43,8 +45,9 @@ def test_draw_graph():
assert draw_graph(graph, layout_function=planar_layout)


@pytest.mark.usefixtures("no_pydot")
def test_draw_graph_no_pydot():
def test_draw_graph_no_pydot(no_pydot):
pytest.importorskip("matplotlib")

from networkx import DiGraph

from jobflow.utils.graph import draw_graph
Expand All @@ -53,8 +56,7 @@ def test_draw_graph_no_pydot():
assert draw_graph(graph)


@pytest.mark.usefixtures("no_matplotlib")
def test_draw_graph_no_matplotlib():
def test_draw_graph_no_matplotlib(no_matplotlib):
from networkx import DiGraph

import jobflow.utils.graph
Expand All @@ -71,6 +73,8 @@ def add(a, b):


def test_to_pydot():
pytest.importorskip("pydot")

from jobflow import Flow, Job
from jobflow.utils.graph import to_pydot

Expand Down
2 changes: 2 additions & 0 deletions tests/utils/test_uid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


def test_uid():
pytest.importorskip("ulid")

from uuid import UUID

from ulid import ULID
Expand Down
Loading