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

MAGA (Make Azure Green Again) #3436

Merged
merged 7 commits into from
Oct 23, 2019
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
5 changes: 3 additions & 2 deletions ci/azure/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ steps:
--no-deps \
--pre \
--upgrade \
numpy \
matplotlib \
pandas \
scipy
# numpy \ # FIXME https://github.com/pydata/xarray/issues/3409
pip install \
--no-deps \
--upgrade \
git+https://github.com/dask/dask \
git+https://github.com/dask/distributed \
git+https://github.com/zarr-developers/zarr \
git+https://github.com/Unidata/cftime
git+https://github.com/Unidata/cftime.git@refs/pull/127/merge
# git+https://github.com/Unidata/cftime # FIXME PR 127 not merged yet
condition: eq(variables['UPSTREAM_DEV'], 'true')
displayName: Install upstream dev dependencies

Expand Down
72 changes: 43 additions & 29 deletions ci/min_deps_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timedelta
from typing import Dict, Iterator, Tuple
from typing import Dict, Iterator, Optional, Tuple

import yaml

Expand Down Expand Up @@ -34,10 +34,14 @@ def error(msg: str) -> None:
print("ERROR:", msg)


def parse_requirements(fname) -> Iterator[Tuple[str, int, int]]:
def warning(msg: str) -> None:
print("WARNING:", msg)


def parse_requirements(fname) -> Iterator[Tuple[str, int, int, Optional[int]]]:
"""Load requirements/py36-min-all-deps.yml

Yield (package name, major version, minor version)
Yield (package name, major version, minor version, [patch version])
"""
global has_errors

Expand All @@ -52,15 +56,18 @@ def parse_requirements(fname) -> Iterator[Tuple[str, int, int]]:
if pkg.endswith("<") or pkg.endswith(">") or eq != "=":
error("package should be pinned with exact version: " + row)
continue

try:
major, minor = version.split(".")
except ValueError:
error("expected major.minor (without patch): " + row)
continue
try:
yield pkg, int(major), int(minor)
version_tup = tuple(int(x) for x in version.split("."))
except ValueError:
error("failed to parse version: " + row)
raise ValueError("non-numerical version: " + row)

if len(version_tup) == 2:
yield (pkg, *version_tup, None) # type: ignore
elif len(version_tup) == 3:
yield (pkg, *version_tup) # type: ignore
else:
raise ValueError("expected major.minor or major.minor.patch: " + row)


def query_conda(pkg: str) -> Dict[Tuple[int, int], datetime]:
Expand All @@ -80,9 +87,9 @@ def query_conda(pkg: str) -> Dict[Tuple[int, int], datetime]:
label = label.strip()
if label == "file name":
value = value.strip()[len(pkg) :]
major, minor = value.split("-")[1].split(".")[:2]
major = int(major)
minor = int(minor)
smajor, sminor = value.split("-")[1].split(".")[:2]
major = int(smajor)
minor = int(sminor)
if label == "timestamp":
assert major is not None
assert minor is not None
Expand All @@ -109,17 +116,15 @@ def query_conda(pkg: str) -> Dict[Tuple[int, int], datetime]:


def process_pkg(
pkg: str, req_major: int, req_minor: int
) -> Tuple[str, int, int, str, int, int, str, str]:
pkg: str, req_major: int, req_minor: int, req_patch: Optional[int]
) -> Tuple[str, str, str, str, str, str]:
"""Compare package version from requirements file to available versions in conda.
Return row to build pandas dataframe:

- package name
- major version in requirements file
- minor version in requirements file
- major.minor.[patch] version in requirements file
- publication date of version in requirements file (YYYY-MM-DD)
- major version suggested by policy
- minor version suggested by policy
- major.minor version suggested by policy
- publication date of version suggested by policy (YYYY-MM-DD)
- status ("<", "=", "> (!)")
"""
Expand All @@ -130,7 +135,7 @@ def process_pkg(
req_published = versions[req_major, req_minor]
except KeyError:
error("not found in conda: " + pkg)
return pkg, req_major, req_minor, "-", 0, 0, "-", "(!)"
return pkg, fmt_version(req_major, req_minor, req_patch), "-", "-", "-", "(!)"

policy_months = POLICY_MONTHS.get(pkg, POLICY_MONTHS_DEFAULT)
policy_published = datetime.now() - timedelta(days=policy_months * 30)
Expand All @@ -153,30 +158,39 @@ def process_pkg(
else:
status = "="

if req_patch is not None:
warning("patch version should not appear in requirements file: " + pkg)
status += " (w)"

return (
pkg,
req_major,
req_minor,
fmt_version(req_major, req_minor, req_patch),
req_published.strftime("%Y-%m-%d"),
policy_major,
policy_minor,
fmt_version(policy_major, policy_minor),
policy_published_actual.strftime("%Y-%m-%d"),
status,
)


def fmt_version(major: int, minor: int, patch: int = None) -> str:
if patch is None:
return f"{major}.{minor}"
else:
return f"{major}.{minor}.{patch}"


def main() -> None:
fname = sys.argv[1]
with ThreadPoolExecutor(8) as ex:
futures = [
ex.submit(process_pkg, pkg, major, minor)
for pkg, major, minor in parse_requirements(fname)
ex.submit(process_pkg, pkg, major, minor, patch)
for pkg, major, minor, patch in parse_requirements(fname)
]
rows = [f.result() for f in futures]

print("Package Required Policy Status")
print("------------- ----------------- ----------------- ------")
fmt = "{:13} {:>1d}.{:<2d} ({:10}) {:>1d}.{:<2d} ({:10}) {}"
print("Package Required Policy Status")
print("------------- -------------------- -------------------- ------")
fmt = "{:13} {:7} ({:10}) {:7} ({:10}) {}"
for row in rows:
print(fmt.format(*row))

Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/py36-min-all-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
- cartopy=0.17
- cdms2=3.1
- cfgrib=0.9
- cftime=1.0.3
- cftime=1.0.3 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
- coveralls
- dask=1.2
- distributed=1.27
Expand Down
4 changes: 2 additions & 2 deletions ci/requirements/py36.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- cartopy
- cdms2
- cfgrib
- cftime=1.0.3.4
- cftime<1.0.4 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
- coveralls
- dask
- distributed
Expand All @@ -25,7 +25,7 @@ dependencies:
- nc-time-axis
- netcdf4
- numba
- numpy
- numpy<1.18 # FIXME https://github.com/pydata/xarray/issues/3409
- pandas
- pint
- pip
Expand Down
6 changes: 3 additions & 3 deletions ci/requirements/py37-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ dependencies:
- bottleneck
- cartopy
# - cdms2 # Not available on Windows
# - cfgrib>=0.9.2 # Causes Python interpreter crash on Windows
- cftime=1.0.3.4
# - cfgrib # Causes Python interpreter crash on Windows
- cftime<1.0.4 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
- coveralls
- dask
- distributed
Expand All @@ -25,7 +25,7 @@ dependencies:
- nc-time-axis
- netcdf4
- numba
- numpy
- numpy<1.18 # FIXME https://github.com/pydata/xarray/issues/3409
- pandas
- pint
- pip
Expand Down
4 changes: 2 additions & 2 deletions ci/requirements/py37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- cartopy
- cdms2
- cfgrib
- cftime=1.0.3.4
- cftime<1.0.4 # FIXME need 1.0.5 (not released yet); 1.0.4 is broken
- coveralls
- dask
- distributed
Expand All @@ -25,7 +25,7 @@ dependencies:
- nc-time-axis
- netcdf4
- numba
- numpy
- numpy<1.18 # FIXME https://github.com/pydata/xarray/issues/3409
- pandas
- pint
- pip
Expand Down
2 changes: 1 addition & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Bug fixes
but cloudpickle isn't (:issue:`3401`) by `Rhys Doyle <https://github.com/rdoyle45>`_

- Sync with cftime by removing `dayofwk=-1` for cftime>=1.0.4.
By `Anderson Banihirwe <https://github.com/andersy005>`_.
By `Anderson Banihirwe <https://github.com/andersy005>`_.


Documentation
Expand Down