Skip to content

Commit

Permalink
run pre-commit formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre committed Sep 27, 2024
1 parent 0b80785 commit 43412e1
Show file tree
Hide file tree
Showing 26 changed files with 62 additions and 56 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,3 @@ Then run::
$ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags

4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"IPython.sphinxext.ipython_console_highlighting",
"nbsphinx",
"pywps.ext_autodoc",
]
]

# To avoid having to install these and burst memory limit on ReadTheDocs.
# List of all tested working mock imports from all birds so new birds can
Expand Down Expand Up @@ -102,7 +102,7 @@

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = {'.rst': 'restructuredtext'}
source_suffix = {".rst": "restructuredtext"}

# The master toctree document.
master_doc = "index"
Expand Down
2 changes: 0 additions & 2 deletions rook/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""Top-level package for rook."""
from .__version__ import __author__, __email__, __version__ # noqa: F401

Expand Down
2 changes: 0 additions & 2 deletions rook/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# This information is located in its own file so that it can be loaded
# without importing the main package when its dependencies are not installed.
# See: https://packaging.python.org/guides/single-sourcing-package-version
Expand Down
2 changes: 1 addition & 1 deletion rook/catalog/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class DBCatalog(Catalog):
def __init__(self, project, url=None):
super(DBCatalog, self).__init__(project)
super().__init__(project)
self.table_name = f"rook_catalog_{self.project}".replace("-", "_")
self.intake_catalog = IntakeCatalog(project, url)

Expand Down
20 changes: 14 additions & 6 deletions rook/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run_process_action(action=None):
and return a status message."""
action = action or "status"
try:
with open(PID_FILE, "r") as fp:
with open(PID_FILE) as fp:
pid = int(fp.read())
p = psutil.Process(pid)
if action == "stop":
Expand All @@ -65,7 +65,7 @@ def run_process_action(action=None):
)
if action == "stop":
os.remove(PID_FILE)
except IOError:
except OSError:
msg = 'No PID file found. Service not running? Try "netstat -nlp | grep :5000".'
except psutil.NoSuchProcess as e:
msg = e.msg
Expand Down Expand Up @@ -172,8 +172,16 @@ def stop():
default="sqlite:///pywps-logs.sqlite",
help="database in PyWPS configuration",
)
@click.option('--outputurl', default='', help='base URL for file downloads')
@click.option('--outputpath', default='', help='base directory where outputs are written')
@click.option(
"--outputurl",
default="",
help="base URL for file downloads"
)
@click.option(
"--outputpath",
default="",
help="base directory where outputs are written"
)
def start(
config,
bind_host,
Expand Down Expand Up @@ -206,8 +214,8 @@ def start(
wps_log_level=log_level,
wps_log_file=log_file,
wps_database=database,
wps_outputurl = outputurl,
wps_outputpath = outputpath
wps_outputurl=outputurl,
wps_outputpath=outputpath,
)
)
if config:
Expand Down
2 changes: 1 addition & 1 deletion rook/dashboard/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ <h3>Data Transfer</h3>
{{ script_t1 | safe }}
{{ script_t2 | safe }}

{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion rook/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from roocs_utils.utils.file_utils import is_file_list, FileMapper


class Operator(object):
class Operator:
# Sub-classes require "prefix" property
prefix = NotImplemented

Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_average_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self):
),
]

super(AverageByDimension, self).__init__(
super().__init__(
self._handler,
identifier="average",
title="Average by Dimensions",
Expand Down
4 changes: 2 additions & 2 deletions rook/processes/wps_average_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):
"shape",
"Vector Shape",
abstract="An ESRI Shapefile, GML, GeoPackage, JSON or GeoJSON file."
" The ESRI Shapefile must be zipped and contain the .shp, .shx, and .dbf.",
" The ESRI Shapefile must be zipped and contain the .shp, .shx, and .dbf.",
supported_formats=[
FORMATS.GML,
FORMATS.GEOJSON,
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(self):
),
]

super(AverageByShape, self).__init__(
super().__init__(
self._handler,
identifier="average_shape",
title="Average over polygonal shape",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_average_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self):
),
]

super(AverageByTime, self).__init__(
super().__init__(
self._handler,
identifier="average_time",
title="Average by Time",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_average_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self):
),
]

super(WeightedAverage, self).__init__(
super().__init__(
self._handler,
identifier="weighted_average",
title="Weighted Average",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(self):
),
]

super(Concat, self).__init__(
super().__init__(
self._handler,
identifier="concat",
title="Concat",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self):
),
]

super(DashboardProcess, self).__init__(
super().__init__(
self._handler,
identifier="dashboard",
title="Dashboard",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_orchestrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self):
),
]

super(Orchestrate, self).__init__(
super().__init__(
self._handler,
identifier="orchestrate",
title="Orchestrate",
Expand Down
4 changes: 2 additions & 2 deletions rook/processes/wps_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self):
"0pt75deg",
"1deg",
"1pt25deg",
"2pt5deg"
"2pt5deg",
],
default="auto",
),
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self):
),
]

super(Regrid, self).__init__(
super().__init__(
self._handler,
identifier="regrid",
title="Regrid",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self):
),
]

super(Subset, self).__init__(
super().__init__(
self._handler,
identifier="subset",
title="Subset",
Expand Down
2 changes: 1 addition & 1 deletion rook/processes/wps_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self):
),
]

super(Usage, self).__init__(
super().__init__(
self._handler,
identifier="usage",
title="Usage",
Expand Down
2 changes: 1 addition & 1 deletion rook/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ROOCS = Namespace("roocs", uri="urn:roocs:")


class Provenance(object):
class Provenance:
def __init__(self, output_dir):
if isinstance(output_dir, pathlib.Path):
self.output_dir = output_dir
Expand Down
4 changes: 2 additions & 2 deletions rook/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def build_tree(wfdoc):
return tree


class WorkflowRunner(object):
class WorkflowRunner:
def __init__(self, output_dir):
self.workflow = Workflow(output_dir)

Expand All @@ -80,7 +80,7 @@ def provenance(self):
return self.workflow.prov


class BaseWorkflow(object):
class BaseWorkflow:
def __init__(self, output_dir):
self.concat_op = Concat(output_dir)
self.subset_op = Subset(output_dir)
Expand Down
24 changes: 12 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
REQUIRES_PYTHON = ">=3.9.0"

about = {}
with open(os.path.join(here, "rook", "__version__.py"), "r") as f:
with open(os.path.join(here, "rook", "__version__.py")) as f:
exec(f.read(), about)

requirements = [line.strip() for line in open('requirements.txt')]
dev_reqs = [line.strip() for line in open('requirements_dev.txt')]
requirements = [line.strip() for line in open("requirements.txt")]
dev_reqs = [line.strip() for line in open("requirements_dev.txt")]

classifiers = [
"Development Status :: 3 - Alpha",
Expand All @@ -36,28 +36,28 @@
]

setup(
name='roocs-rook',
version=about['__version__'],
name="roocs-rook",
version=about["__version__"],
description="A WPS service for roocs.",
long_description=README + '\n\n' + CHANGES,
long_description=README + "\n\n" + CHANGES,
long_description_content_type="text/x-rst",
author=about['__author__'],
author_email=about['__email__'],
url='https://github.com/roocs/rook',
author=about["__author__"],
author_email=about["__email__"],
url="https://github.com/roocs/rook",
python_requires=REQUIRES_PYTHON,
classifiers=classifiers,
license="Apache Software License 2.0",
zip_safe=False,
keywords='wps pywps birdhouse rook',
keywords="wps pywps birdhouse rook",
packages=find_packages(),
include_package_data=True,
install_requires=requirements,
extras_require={
"dev": dev_reqs, # pip install ".[dev]"
},
entry_points={
'console_scripts': [
'rook=rook.cli:cli',
"console_scripts": [
"rook=rook.cli:cli",
]
},
)
4 changes: 2 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get(self, *args, **kwargs):
query = "?"
for key, value in kwargs.items():
query += "{}={}&".format(key, value)
return super(WpsTestClient, self).get(query)
return super().get(query)


def client_for(service):
Expand Down Expand Up @@ -100,6 +100,6 @@ def get_output(doc):

def extract_paths_from_metalink(path):
path = path.replace("file://", "")
doc = BeautifulSoup(open(path, "r").read(), "xml")
doc = BeautifulSoup(open(path).read(), "xml")
paths = [el.text.replace("file://", "") for el in doc.find_all("metaurl")]
return paths
20 changes: 12 additions & 8 deletions tests/test_wps_average_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@
from .common import PYWPS_CFG, get_output, extract_paths_from_metalink


POLY = Polygon([[5.8671874999999996, 57.326521225217064],
[-15.468749999999998, 48.45835188280866],
[-16.171875, 24.84656534821976],
[-3.8671874999999996, 13.581920900545844],
[21.796875, 25.799891182088334],
[22.8515625, 52.482780222078226],
[5.8671874999999996, 57.326521225217064]])
POLY = Polygon(
[
[5.8671874999999996, 57.326521225217064],
[-15.468749999999998, 48.45835188280866],
[-16.171875, 24.84656534821976],
[-3.8671874999999996, 13.581920900545844],
[21.796875, 25.799891182088334],
[22.8515625, 52.482780222078226],
[5.8671874999999996, 57.326521225217064],
]
)


def test_wps_average_shape_cmip6(tmp_path):
# Save POLY to tmpdir
tmp_poly_path = tmp_path / "tmppoly.json"
gpd.GeoDataFrame([{'geometry': POLY}]).to_file(tmp_poly_path)
gpd.GeoDataFrame([{"geometry": POLY}]).to_file(tmp_poly_path)

# test the case where the inventory is used
client = client_for(Service(processes=[AverageByShape()], cfgfiles=[PYWPS_CFG]))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wps_orchestrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_wps_orchestrate_c3s_cmip6_subset_metadata():
m_path = get_output(resp.xml)["output"]
# print(m_path)
# parse metalink
xml = open(m_path[7:], "r").read()
xml = open(m_path[7:]).read()
urls = parse_metalink(xml)
# print(urls)
ds = xr.open_dataset(urls[0][7:], use_cftime=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wps_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_wps_subset_c3s_cmip6_metadata():
m_path = get_output(resp.xml)["output"]
assert "meta4" in m_path
# parse metalink
xml = open(m_path[7:], "r").read()
xml = open(m_path[7:]).read()
urls = parse_metalink(xml)
# print(urls)
ds = xr.open_dataset(urls[0][7:], use_cftime=True)
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ deps =
; -r{toxinidir}/requirements.txt
commands =
pytest --basetemp={envtmpdir}

0 comments on commit 43412e1

Please sign in to comment.