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

Investigate upstream issue with netcdf4==1.7.1 on Linux. Pin netcdf4 for now #215

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 86fa907
_commit: 0bdf6b4
_src_path: gh:blakeNaccarato/copier-python
actions_runner: ubuntu-22.04
active: true
Expand Down
26 changes: 22 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@
]
},
{
"id": "version",
"id": "dependency",
"type": "promptString",
"description": "version",
"default": "0.0.1"
"description": "Show tree of packages requesting this dependency."
},
// * -------------------------------------------------------------------------- * //
{
"id": "templateOptions",
"description": "Template options.",
"type": "pickString",
"options": ["", "-Stay", "-Stay -Prompt", "-Recopy -Prompt"]
},
{
"id": "changeType",
"description": "Change type.",
"type": "pickString",
"options": ["breaking", "deprecation", "change"]
}
],
"tasks": [
Expand Down Expand Up @@ -288,6 +292,20 @@
// * -------------------------------------------------------------------------- * //
// * OTHER TASKS * //

{
"label": "task: Generate changelog entry",
"type": "shell",
"command": ". scripts/Initialize-Shell.ps1; python -m boilercv_tools add-change ${input:changeType}",
"icon": { "id": "request-changes" },
"problemMatcher": []
},
{
"label": "task: Show tree of packages requesting a dependency",
"type": "shell",
"command": ". scripts/Initialize-Shell.ps1; pipdeptree --reverse --packages ${input:dependency}",
"icon": { "id": "versions" },
"problemMatcher": []
},
{
"label": "task: Run pytest with coverage",
"type": "shell",
Expand Down
1 change: 1 addition & 0 deletions changelog/215.change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Investigate upstream issue with `netcdf4==1.7.1` on Linux. Pin `netcdf4` for now
6 changes: 6 additions & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies = [
"shapely>=2.0.3",
"sympy>=1.12",
"trackpy>=0.6.2",
# ? https://nvd.nist.gov/vuln/detail/CVE-2024-37891
# ? via sphinx
"urllib3>=2.2.2",
]

[tool.fawltydeps]
Expand Down Expand Up @@ -65,6 +68,9 @@ ignore_unused = [
"sphinxcontrib-bibtex",
"sphinxcontrib-mermaid",
"sphinxcontrib-towncrier",
# ? https://nvd.nist.gov/vuln/detail/CVE-2024-37891
# ? via sphinx
"urllib3",
]
[tool.fawltydeps.custom_mapping]
ipykernel = ["IPython"]
Expand Down
28 changes: 18 additions & 10 deletions lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ dependencies = [
"sympy>=1.12",
"xarray[accel,io,parallel]>=2023.7.0",
# ? https://github.com/softboiler/boilercv/issues/213
"netcdf4>=1.7.0",
"netcdf4!=1.7.1 ; sys_platform == 'linux'",
"netcdf4>=1.6.5",
"netcdf4!=1.7.1.post1 ; sys_platform == 'linux'",
]
[project.optional-dependencies]
# * Minimal CV flavor needed, but allow `boilercv` to coexist with different flavors
Expand Down
1 change: 1 addition & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fawltydeps==0.15.0
flit==3.9.0
keyring==25.2.1
pandas-stubs~=2.2.2
pipdeptree==2.23.0
pre-commit==3.7.1
pyright==1.1.367
ruff==0.4.8
Expand Down
30 changes: 16 additions & 14 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ billiard==4.2.0
bleach==6.1.0
blosc2==2.7.0
boilercine @ git+https://github.com/blakeNaccarato/boilercine@046ee0146394bebf5693fe0c18bbcea3d3e64fe5
bokeh==3.4.1
bokeh==3.4.2
bottleneck==1.4.0
cachetools==5.3.3
cachier @ git+https://github.com/blakeNaccarato/cachier@0892f53dc8fd9fb8a7f959305a1a9ec692876dc0
Expand All @@ -52,7 +52,7 @@ configobj==5.0.8
contourpy==1.2.1
copier==9.2.0
copykitten==1.1.1
coverage==7.5.3
coverage==7.5.4
cryptography==42.0.8
cycler==0.12.1
cyclopts==2.7.0
Expand Down Expand Up @@ -89,7 +89,7 @@ executing==2.0.1
fasteners==0.19
fastjsonschema==2.20.0
fawltydeps==0.15.0
filelock==3.15.3
filelock==3.15.4
fiona==1.9.6
flatten-dict==0.4.2
flit-core==3.9.0
Expand All @@ -106,14 +106,14 @@ geopandas==0.14.3
gitdb==4.0.11
gitpython==3.1.43
gmpy2==2.1.5
google-api-core==2.19.0
google-api-core==2.19.1
google-auth-oauthlib==1.2.0
google-auth==2.30.0
google-cloud-core==2.4.1
google-cloud-storage==2.17.0
google-crc32c==1.5.0
google-resumable-media==2.7.1
googleapis-common-protos==1.63.1
googleapis-common-protos==1.63.2
grandalf==0.8
greenlet==3.0.3
gto==1.7.1
Expand All @@ -125,7 +125,7 @@ identify==2.5.36
idna==3.7
imageio==2.34.1
imagesize==1.4.1
importlib-metadata==7.2.0
importlib-metadata==8.0.0
incremental==22.10.0
iniconfig==2.0.0
ipykernel==6.29.4
Expand Down Expand Up @@ -176,7 +176,7 @@ nbconvert==7.7.3
nbformat==5.10.4
ndindex==1.8
nest-asyncio==1.6.0
netcdf4==1.7.0
netcdf4==1.6.5
networkx==3.3
nodeenv==1.9.1
nptyping==2.5.0
Expand All @@ -196,27 +196,29 @@ packaging==24.1
pandas-stubs==2.2.2.240514
pandas==2.2.2
pandocfilters==1.5.1
param==2.1.0
param==2.1.1
parso==0.8.4
partd==1.4.2
pathspec==0.12.1
pathtools==0.1.2
pexpect==4.9.0
pillow==10.3.0
pip-requirements-parser==32.0.1
pip==24.1
pipdeptree==2.23.0
pipx==1.6.0
platformdirs==3.11.0
ploomber-core==0.2.25
ploomber-engine==0.0.30
pluggy==1.5.0
plumbum==1.8.3
pooch==1.8.2
portalocker==2.8.2
portalocker==2.10.0
posthog==3.5.0
pre-commit==3.7.1
prompt-toolkit==3.0.47
proto-plus==1.24.0
protobuf==4.25.3
protobuf==5.27.2
psutil==6.0.0
ptyprocess==0.7.0
pure-eval==0.2.2
Expand All @@ -232,7 +234,7 @@ pycparser==2.22
pyct==0.5.0
pydantic-core==2.18.2
pydantic==2.7.1
pydata-sphinx-theme==0.15.3
pydata-sphinx-theme==0.15.4
pydot==2.0.0
pygit2==1.15.0
pygments==2.18.0
Expand Down Expand Up @@ -279,7 +281,7 @@ seaborn==0.13.2
secretstorage==3.3.3
semver==3.0.2
setproctitle==1.3.3
setuptools==70.1.0
setuptools==70.1.1
shapely==2.0.3
shellingham==1.5.4
shiboken6==6.7.1
Expand Down Expand Up @@ -342,8 +344,8 @@ urllib3==2.2.2
userpath==1.9.2
uvicorn==0.30.1
vine==5.1.0
virtualenv==20.26.2
voluptuous==0.14.2
virtualenv==20.26.3
voluptuous==0.15.0
watchdog==4.0.1
watchfiles==0.22.0
wcwidth==0.2.13
Expand Down
12 changes: 10 additions & 2 deletions scripts/boilercv_tools/__main__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""CLI for tools."""

import tomllib
from collections.abc import Collection
from pathlib import Path
from re import finditer, sub
from shlex import join, split
from tomllib import loads

from cyclopts import App

from boilercv_tools import add_changes
from boilercv_tools.sync import PYTEST, check_compilation, escape
from boilercv_tools.types import ChangeType

APP = App(help_format="markdown")
"""CLI."""
Expand All @@ -24,6 +26,12 @@ def compile(high: bool = False): # noqa: A001
log(check_compilation(high))


@APP.command
def add_change(change: ChangeType = "change"):
"""Add change."""
add_changes.add_change(change)


@APP.command
def get_actions():
"""Get actions used by this repository.
Expand Down Expand Up @@ -59,7 +67,7 @@ def sync_local_dev_configs():
shadowing. Concurrent test runs are disabled in the local pytest configuration which
slows down the usual local, granular test workflow.
"""
config = tomllib.loads(Path("pyproject.toml").read_text("utf-8"))
config = loads(Path("pyproject.toml").read_text("utf-8"))
pytest = config["tool"]["pytest"]["ini_options"]
pytest["addopts"] = disable_concurrent_tests(pytest["addopts"])
PYTEST.write_text(
Expand Down
131 changes: 131 additions & 0 deletions scripts/boilercv_tools/add_changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
"""Add changes."""

from dataclasses import dataclass
from json import loads
from re import sub
from shlex import quote, split
from subprocess import run
from textwrap import dedent
from typing import Any, NamedTuple
from urllib.parse import urlparse

from dulwich.repo import Repo

from boilercv_tools.types import ChangeType


def add_change(typ: ChangeType = "change"):
"""Add change."""
owner, repo, issue = get_issue_from_active_branch()
change = get_change(owner, repo, issue)
content = quote(f"{change.name}\n")
run(
split( # noqa: S603
f"""towncrier create --content {content} {change.id}.{typ}.md"""
),
check=True,
)


class Issue(NamedTuple):
"""Issue."""

owner: str
"""Owner."""
repo: str
"""Repository."""
issue: int
"""Issue."""


def get_issue_from_active_branch() -> Issue:
"""Get issue associated with active branch."""
repository = Repo(".")
owner, repo = (
urlparse(repository.get_config().get(("remote", "origin"), "url"))
.path.decode("utf-8")
.removesuffix(".git")
.strip("/")
.split("/")
)
(_, ref), _ = repository.refs.follow(b"HEAD")
issue = ref.decode("utf-8").split("/")[-1].split("=")[0].split("-")[0]
return Issue(owner, repo, issue)


@dataclass
class Change:
"""Change."""

id: int
"""ID."""
name: str
"""Name."""


def get_change(owner: str, repo: str, issue: int) -> Change:
"""Get related issue title."""
first = 1
if nodes := get_connected_prs(owner, repo, issue, first):
subject = nodes[0]["subject"]
return Change(id=subject["number"], name=subject["title"])
return Change(id=issue, name=query_gh_issue(owner, repo, issue)["title"])


def get_connected_prs(
owner: str, repo: str, issue: int, first: int
) -> list[dict[str, Any]]:
"""Get first PR connected to an issue."""
return query_gh_issue(
owner,
repo,
issue,
query=f"""
timelineItems(itemTypes: CONNECTED_EVENT, first: {first}) {{
nodes {{
... on ConnectedEvent {{
subject {{ ... on PullRequest {{ number title }} }}
}}
}}
}}""",
)["timelineItems"]["nodes"]


def query_gh_issue(
owner: str, repo: str, issue: int, query: str = "title"
) -> dict[str, Any]:
"""Query GitHub for an issue."""
result = run(
[ # noqa: S603, S607
"gh",
"api",
"graphql",
"-f",
sanitize(f"""query= {{
repository(owner:"{owner}", name:"{repo}") {{
issue(number: {issue}) {{ {sanitize(query)} }}
}}
}}"""),
],
capture_output=True,
text=True,
check=False,
)
if result.returncode:
raise RuntimeError(result.stderr)
data = loads(result.stdout)["data"].get("repository")
if not data:
raise RuntimeError("Query does not return a repository.")
if data := data.get("issue"):
return data
else:
raise RuntimeError("Query does not return an issue.")


def sanitize(query: str) -> str:
"""Sanitize query."""
return sub(r"\s+", " ", f"{dedent(query)}").strip().replace("\n", "")


if __name__ == "__main__":
add_change()
2 changes: 2 additions & 0 deletions scripts/boilercv_tools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"""Allowable operator."""
ops: tuple[Op, ...] = (" @ ", "==")
"""Allowable operators."""
ChangeType: TypeAlias = Literal["breaking", "deprecation", "change"]
"""Type of change to add to changelog."""


class Dep(TypedDict):
Expand Down
Loading