Skip to content

Commit

Permalink
Merge pull request #79 from roocs/fix-workflow-chain
Browse files Browse the repository at this point in the history
Fix workflow chain
  • Loading branch information
cehbrecht committed Dec 17, 2020
2 parents e18665f + b641a59 commit c19961e
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
default_language_version:
python: python3

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: trailing-whitespace
language_version: python3
exclude: setup.cfg
- id: end-of-file-fixer
language_version: python3
exclude: setup.cfg
- id: check-yaml
language_version: python3
- id: debug-statements
language_version: python3
- repo: https://github.com/ambv/black
rev: 20.8b1
hooks:
- id: black
language_version: python3
args: ["--target-version", "py36"]
- repo: https://github.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
language_version: python3
args: ['--config=setup.cfg']
#- repo: https://github.com/pre-commit/mirrors-autopep8
# rev: v1.4.4
# hooks:
# - id: autopep8
# args: ['--global-config=setup.cfg','--in-place']
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
hooks:
- id: isort
language_version: python3
args: ['--profile', 'black']
#- repo: https://github.com/pycqa/pydocstyle
# rev: 5.0.2
# hooks:
# - id: pydocstyle
# args: ["--conventions=numpy"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.3
hooks:
- id: pyupgrade
language_version: python3
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
# - repo: https://github.com/kynan/nbstripout
# rev: 0.3.9
# hooks:
# - id: nbstripout
# language_version: python3
# files: ".ipynb"
4 changes: 3 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ sphinx>=1.7
bumpversion
twine
cruft
# Changing dependencies above this comment will create merge conflicts when updating the cookiecutter template with cruft. Add extra requirements below this line.
# Changing dependencies above this comment will create merge conflicts when updating the cookiecutter template with cruft. Add extra requirements below this line.
black
pre-commit
20 changes: 19 additions & 1 deletion rook/operator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import os
import tempfile


def _resolve_collection_if_files(outputs):
# If multiple outputs are files with a common directory name, then
# return that as a single output

if len(outputs) > 1:
first_dir = os.path.dirname(outputs[0])

if all([os.path.isfile(output) for output in outputs]):
if os.path.dirname(os.path.commonprefix(outputs)) == first_dir:
return first_dir

return outputs[0]


class Operator(object):
def __init__(self, output_dir, apply_fixes=True):
self.config = {
Expand All @@ -17,12 +32,15 @@ def call(self, args, collection):

class Subset(Operator):
def call(self, args):
# Convert file list to directory if required
collection = _resolve_collection_if_files(args.get("collection"))

# TODO: handle lazy load of daops
from daops.ops.subset import subset

# from .tweaks import subset
kwargs = dict(
collection=args.get("collection"),
collection=collection,
time=args.get("time"),
level=args.get("level"),
area=args.get("area"),
Expand Down

0 comments on commit c19961e

Please sign in to comment.