Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

cate-1041: Writing feature collection fails #1042

Merged
merged 12 commits into from
Mar 2, 2023
62 changes: 43 additions & 19 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,66 @@
# version here is only relevant for the AppVeyor CI, no need to adjust
version: '{build}'

image:
- macOS
- Ubuntu2004

platform:
- x64

environment:
global:
PYTHON_LOC: "C:\\Miniconda37-x64"
# For the unit-tests, disable Numba JIT, otherwise Coverage wont reach the actual Python code
NUMBA_DISABLE_JIT: 1
# Uncomment following line if web testing breaks our build
CATE_DISABLE_WEB_TESTS: 1
# geopandas in tests break the build on appveyor (maybe the problem of gdal?)
CATE_DISABLE_GEOPANDAS_TESTS: 1
CATE_DISABLE_PLOT_TESTS: 1
CATE_DISABLE_CLI_UPDATE_TESTS: 1

for:
-
matrix:
only:
- image: macOS
install:
- curl -L https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh > miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
-
matrix:
only:
- image: Ubuntu2004
install:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda

install:
- call %PYTHON_LOC%\Scripts\activate.bat
build_script:
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda config --set channel_priority strict
- conda update -q conda
- conda info -a
- conda install -c conda-forge -n base mamba
- conda init bash
- export CONDA_BASE=$(conda info --base)
- source $CONDA_BASE/etc/profile.d/conda.sh
- conda install -c conda-forge -n base mamba pip

build_script:
- call %PYTHON_LOC%\Scripts\activate.bat
- git clone https://github.com/dcs4cop/xcube.git
- git clone https://github.com/dcs4cop/xcube-cci.git
# Install xcube env and xcube
- cd xcube
- mamba env create
- conda activate xcube
- python setup.py develop
- pip install -e .
# Install xcube-cci
- cd ..\xcube-cci
- cd ..
- cd xcube-cci
- mamba install -c conda-forge lxml pydap aiohttp nest-asyncio
- python setup.py develop
- pip install -e .
# Install cate-specific packages
- cd ..
- mamba install -c conda-forge cartopy
- python setup.py develop
- pip install -e .
- conda list
# For the unit-tests, disable Numba JIT, otherwise Coverage wont reach the actual Python code
- set NUMBA_DISABLE_JIT=1
# Uncomment following line if web testing on travis breaks our build
- set CATE_DISABLE_WEB_TESTS=1
# geopandas in tests break the build on appveyor (maybe the problem of gdal?)
- set CATE_DISABLE_GEOPANDAS_TESTS=1
- set CATE_DISABLE_PLOT_TESTS=1
- set CATE_DISABLE_CLI_UPDATE_TESTS=1
- pytest -v --cov=cate tests
12 changes: 12 additions & 0 deletions cate/webapi/geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ def write_feature_collection(feature_collection: Union[fiona.Collection, Iterabl
if num_features_written > 0:
io.write(',\n')
io.flush()
# fiona >=1.9 returns features of type fiona.model.Feature
# rather than JSON-serializable dictionaries.
if hasattr(feature, '__geo_interface__'):
# We fall back on the traditional geo-interface:
feature = feature.__geo_interface__
# Fiona =1.9.0 adds empty "geometries" field
# to any "geometry", we fix this too:
geometry = feature.get('geometry')
if geometry \
and "geometries" in geometry \
and geometry.get("type") != "GeometryCollection":
del geometry["geometries"]
if res_id is not None:
feature['_resId'] = res_id
feature['_idx'] = feature_index
Expand Down
2 changes: 1 addition & 1 deletion tests/ops/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_alloc_memory(self):
no_op(step_duration=0, num_steps=3, memory_alloc='120M')
no_op(step_duration=0, num_steps=200, memory_alloc='124B')
no_op(step_duration=0, num_steps=2, memory_alloc='0.1G')
no_op(step_duration=0, num_steps=1, memory_alloc='0.01T')
no_op(step_duration=0, num_steps=1, memory_alloc='0.001T')
with self.assertRaises(ValueError):
no_op(step_duration=0, num_steps=5, memory_alloc='x')

Expand Down