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

Updated CI #4

Merged
merged 7 commits into from
Oct 24, 2023
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
133 changes: 17 additions & 116 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,132 +11,33 @@ env:
DOCKER_IMAGE_NAME: ${{ github.repository }}

jobs:
# codecov:
# name: codecov
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Execute linters and test suites
# run: ./docker/cibuild
# - name: Upload All coverage to Codecov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml
# fail_ci_if_error: false
python-matrix:
name: python-matrix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
env:
- ci/envs/py310.yaml
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- name: Set up conda cache
uses: actions/cache@v2
- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ hashFiles('**/environment.yml') }}
restore-keys: ${{ runner.os }}-conda-
- name: Set up pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg', '**/requirements-dev.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Set up Conda with Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Update Conda's environemnt
run: conda env update -f environment.yml -n test
- name: Execute linters and test suites
run: ./scripts/cibuild
docker:
name: docker
needs:
# - codecov
- python-matrix
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run rename script if in the template repo
environment-file: ${{ matrix.env }}
- name: Install
run: |
if [[ "$GITHUB_REPOSITORY" == */template ]]; then
scripts/rename
fi
- name: Source build args
python3 -m pip install -e .

- name: Check and Log Environment
run: |
source ./docker_env
STACTOOLS_VERSION=$(python scripts/stactools-version.py)
echo "stactools_version=$STACTOOLS_VERSION" >> $GITHUB_ENV
echo "docker_workdir=$DOCKER_WORKDIR" >> $GITHUB_ENV
echo "docker_namespace_package_dir=$DOCKER_NAMESPACE_PACKAGE_DIR" >> $GITHUB_ENV
-
name: Docker meta main
id: meta-main
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
-
name: Build and push main
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
build-args: |
STACTOOLS_VERSION=${{ env.stactools_version }}
DOCKER_WORKDIR=${{ env.docker_workdir }}
DOCKER_NAMESPACE_PACKAGE_DIR=${{ env.docker_namespace_package_dir }}
# Don't try to push if the event is a PR from a fork
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta-main.outputs.tags }}
labels: ${{ steps.meta-main.outputs.labels }}
-
name: Docker meta dev
id: meta-dev
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
flavor: |
suffix=-dev
tags: |
type=ref,event=branch
type=ref,event=pr
-
name: Build and push dev
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile-dev
build-args: |
STACTOOLS_VERSION=${{ env.stactools_version }}
DOCKER_WORKDIR=${{ env.docker_workdir }}
DOCKER_NAMESPACE_PACKAGE_DIR=${{ env.docker_namespace_package_dir }}
# Don't try to push if the event is a PR from a fork
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta-dev.outputs.tags }}
labels: ${{ steps.meta-dev.outputs.labels }}
python -V
python -c "import geopandas; geopandas.show_versions();"
micromamba info
micromamba list

- name: Execute linters and test suites
run: ./scripts/cibuild

8 changes: 8 additions & 0 deletions ci/envs/py310.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: test
channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- gdal
- cfgrib
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ channels:
- defaults
dependencies:
- gdal
- cfgrib
4 changes: 2 additions & 2 deletions scripts/format
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fi
function usage() {
echo -n \
"Usage: $(basename "$0")
Format code with yapf
Format code with black
"
}

Expand All @@ -22,6 +22,6 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
# Sort imports
isort --overwrite-in-place .
# Code formatting
yapf -ipr ${DIRS_TO_CHECK[@]}
black .
fi
fi
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
# echo ["running ec"]
# ec --exclude "$EC_EXCLUDE"
# Code formatting
echo ["running blck"]
echo ["running black"]
black --check .
# Lint
echo ["running flake8"]
Expand Down
1 change: 1 addition & 0 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then

coverage run --source=${COVERAGE_DIRS} -m unittest discover tests/
coverage xml
pytest tests
fi
fi
7 changes: 4 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ keywords =
classifiers =
Development Status :: 4 - Beta
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12

[options]
package_dir =
= src
packages = find_namespace:
python_requires = >3.10
install_requires =
stactools >= 0.2.6
xarray
Expand Down
3 changes: 2 additions & 1 deletion src/stactools/ecmwf_forecast/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ def create_item_command(asset_href, index_href: str, destination: str):
)
@click.option("-d", "--destination", default="ecmwf-forecast-coverage.png")
def _(destination):
from stactools.ecmwf_forecast import constants, plots
import matplotlib.pyplot as plt

from stactools.ecmwf_forecast import constants, plots

plots.plot_combinations(constants.get_combinations())
plt.savefig(
destination,
Expand Down
1 change: 0 additions & 1 deletion src/stactools/ecmwf_forecast/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Combination(typing.NamedTuple):
FORMATS = ["grib2", "bufr"]
PRESSURE_LEVELS = [1000, 925, 850, 700, 500, 300, 250, 200, 50]


# mypy failing on python 3.7


Expand Down
2 changes: 1 addition & 1 deletion src/stactools/ecmwf_forecast/plots.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
try:
import matplotlib.font_manager
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
except ImportError as e:
raise ImportError(
"stactools.ecmwf_forecast.plots requires matplotlib, pandas, and seaborn."
Expand Down
8 changes: 5 additions & 3 deletions src/stactools/ecmwf_forecast/stac.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

import dataclasses
import operator
import datetime
import itertools
import logging
import operator
import pathlib
import re
from typing import Any
Expand All @@ -20,11 +20,11 @@
SpatialExtent,
TemporalExtent,
)

from . import constants

logger = logging.getLogger(__name__)


xpr = re.compile(
r"(?P<reference_datetime>\d{10})0000-"
r"(?P<step>\d+[h|m])-"
Expand Down Expand Up @@ -417,7 +417,9 @@ def list_sibling_assets(filename) -> list[Parts]:

# mypy failing on python 3.7
combinations = constants.get_combinations() # type: ignore
d = {k: list(v) for k, v in itertools.groupby(combinations, key=_assets_key)} # type: ignore
d = {
k: list(v) for k, v in itertools.groupby(combinations, key=_assets_key)
} # type: ignore
combos = list(d[p.format, p.type, p.reference_datetime.strftime("%H"), p.stream])
prefix = p.prefix or ""

Expand Down
1 change: 0 additions & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# from stactools.ecmwf_forecast.commands import create_ecmwfforecast_command


# class CommandsTest(CliTestCase):

# def create_subcommand_functions(self):
Expand Down