Skip to content
Snippets Groups Projects
Commit c2877bd6 authored by Martin Bergemann's avatar Martin Bergemann :speech_balloon:
Browse files

Add gitlab ci pipeline

parent f55fea35
No related branches found
No related tags found
1 merge request!4Tests
Pipeline #19045 failed
stages:
- test
- report
.template: &pyt_test
stage: test
tags:
- conda
lint:
<< : *py_test
before_script:
- pip install .[test]
script:
- mypy
- black --check src
- pylint src/rechunk_data/__init__.py
test_35:
<< : *py_test
before_script:
- conda env create -q -n test python=3.5 pip
- conda run -n python -m pip install .[test]
script:
- pytest -vv
test_36:
<< : *py_test
before_script:
- conda env create -q -n test python=3.6 pip
- conda run -n python -m pip install .[test]
script:
- pytest -vv
test_37:
<< : *py_test
before_script:
- conda env create -q -n test python=3.7 pip
- conda run -n python -m pip install .[test]
script:
- pytest -vv
test_38:
<< : *py_test
before_script:
- conda env create -q -n test python=3.8 pip
- conda run -n python -m pip install .[test]
script:
- pytest -vv
test_39:
<< : *py_test
before_script:
- conda env create -q -n test python=3.9 pip
- conda run -n python -m pip install .[test]
script:
- pytest -vv
test_latest:
<< : *py_test
before_script:
- conda env create -q -n test python=3.10 pip
- conda run -n python -m pip install .[test]
script:
- pytest -vv
artifacts:
when: always
reports:
junit: report.xml
paths:
- coverage_report
- report.xml
pages:
stage: report
tags:
- conda
dependencies:
- test_latest
before_script:
- mv coverage_report public/
artifacts:
when: always
paths:
- public/
reports:
junit: report.xml
......@@ -35,10 +35,24 @@ setup(
packages=find_packages("src"),
package_dir={"": "src"},
entry_points={
"console_scripts": [f"{find_key(key='ProgramName')} = rechunk_data:cli"]
"console_scripts": [f"{find_key(key='PROGRAM_NAME')} = rechunk_data:cli"]
},
install_requires=["argparse", "dask", "xarray", "h5netcdf", "netCDF4"],
python_requires=">=3.6",
extras_require={
"test": [
"black",
"mock",
"mypy",
"nbformat",
"pytest",
"pytest-html",
"pytest-env",
"pytest-cov",
"testpath",
"types-mock",
],
},
python_requires=">=3.5",
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
......
......@@ -11,19 +11,19 @@ from dask.array.core import Array
import xarray as xr
__version__ = "2206.0.2"
ProgramName = "rechunk-data"
PROGRAM_NAME = "rechunk-data"
logging.basicConfig(
format="%(name)s - %(levelname)s - %(message)s", level=logging.ERROR
)
logger = logging.getLogger(ProgramName)
logger = logging.getLogger(PROGRAM_NAME)
def parse_args(argv: Optional[List[str]]) -> argparse.Namespace:
"""Parse arguments for the command line parser."""
parser = argparse.ArgumentParser(
prog=ProgramName,
prog=PROGRAM_NAME,
description=(
"Rechunk input netcdf data to optimal chunk-size."
" approx. 126 MB per chunk"
......@@ -57,7 +57,9 @@ def parse_args(argv: Optional[List[str]]) -> argparse.Namespace:
type=str,
)
parser.add_argument(
"-v", action="count", default=0,
"-v",
action="count",
default=0,
)
parser.add_argument(
"-V",
......@@ -98,7 +100,9 @@ def _save_dataset(
logger.debug("Saving file ot %s", file_name)
try:
dset.to_netcdf(
file_name, engine=engine, encoding=encoding,
file_name,
engine=engine,
encoding=encoding,
)
except Exception as error:
logger.error("Saving to file failed: %s", error.__str__())
......
......@@ -16,7 +16,10 @@ def create_data(
"""Create a netcdf dataset."""
coords = {d: np.ones(chunk_size[n]) for (n, d) in enumerate(dims)}
dset = xr.DataArray(
np.zeros(chunk_size), dims=dims, coords=coords, name=variable_name,
np.zeros(chunk_size),
dims=dims,
coords=coords,
name=variable_name,
).chunk(dict(zip(dims, chunk_size)))
dset.encoding = {"chunksizes": chunk_size}
return xr.Dataset({variable_name: dset})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment