Skip to content

Commit

Permalink
Merge pull request #17 from NLeSC-GO-common-infrastructure/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
fnattino committed Nov 26, 2021
2 parents 92f99b6 + 8ff950a commit d7e7ff1
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 65 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ jobs:
run: |
which python
python --version
- name: Install dependencies
- name: Install package (with test dependencies)
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build
shell: bash -l {0}
run: |
python setup.py build
python -m pip install -e .[test]
- name: Test
shell: bash -l {0}
run: |
python setup.py test
run: pytest --cov --cov-report xml --cov-report term --cov-report html

15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning <http://semver.org/>`_.


[0.2.1]
*******

Fixed
-----

* Process pool in copy_asset always spawn processes, avoiding issues with async filesystems

Added
-----

* Global configure function


[0.2.0]
*******

Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ authors:
city: Amsterdam
country: NL
email:
date-released: 2021-11-17
version: "0.2.0"
date-released: 2021-11-26
version: "0.2.1"
repository-code: "https://github.com/NLeSC-GO-common-infrastructure/stac2dcache"
keywords:
- STAC
Expand Down
75 changes: 44 additions & 31 deletions notebooks/tutorial.ipynb

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
[metadata]
description-file = README.rst

[aliases]
# Define `python setup.py test`
test=pytest

[coverage:run]
branch = True
source = stac2dcache

[tool:pytest]
testpaths = tests
addopts = --cov --cov-report xml --cov-report term --cov-report html

# Define `python setup.py build_sphinx`
[build_sphinx]
source-dir = docs
Expand Down
19 changes: 9 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
with open('requirements.txt') as requirements_file:
requirements = requirements_file.read().split()

extras_require = {
'test': [
'pytest',
'pytest-cov',
'pycodestyle',
],
}

setup(
name='stac2dcache',
version=version['__version__'],
Expand All @@ -40,16 +48,7 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
test_suite='tests',
python_requires=">=3.7",
install_requires=requirements,
setup_requires=[
# dependency for `python setup.py test`
'pytest-runner',
],
tests_require=[
'pytest',
'pytest-cov',
'pycodestyle',
]
extras_require=extras_require,
)
4 changes: 4 additions & 0 deletions stac2dcache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

import logging

from .configure import configure
from .stac_io import configure_stac_io
from .filesystem import configure_filesystem

logging.getLogger(__name__).addHandler(logging.NullHandler())

fs = None
stac_io = None
2 changes: 1 addition & 1 deletion stac2dcache/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.0'
__version__ = '0.2.1'
21 changes: 21 additions & 0 deletions stac2dcache/configure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import stac2dcache

from .filesystem import configure_filesystem
from .stac_io import configure_stac_io


def configure(username=None, password=None, token_filename=None):
"""
Configure authentication to dCache with either username/passwd or token.
:param username: (optional, str)
:param password: (optional, str)
:param token_filename: (optional, str) path to file with the token
"""
stac2dcache.fs = configure_filesystem(
filesystem="dcache",
username=username,
password=password,
token_filename=token_filename,
)
stac2dcache.stac_io = configure_stac_io(stac2dcache.fs)
7 changes: 6 additions & 1 deletion stac2dcache/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import geopandas
import multiprocessing
import urlpath

from concurrent.futures import ProcessPoolExecutor, as_completed
Expand All @@ -7,6 +8,9 @@
from .filesystem import copy


mp_context = multiprocessing.get_context("spawn")


def catalog2geopandas(catalog, crs=None):
"""
Create a geopandas data-frame with the catalog items
Expand Down Expand Up @@ -59,7 +63,8 @@ def copy_asset(catalog, asset_key, update_catalog=False, item_id=None,
else:
items = catalog.get_all_items()

with ProcessPoolExecutor(max_workers=max_workers) as executor:
with ProcessPoolExecutor(max_workers=max_workers, mp_context=mp_context) \
as executor:

future_to_asset = {}
for item in items:
Expand Down

0 comments on commit d7e7ff1

Please sign in to comment.