Skip to content

Commit c60b607

Browse files
committed
black formatting
1 parent 6813855 commit c60b607

File tree

12 files changed

+257
-49
lines changed

12 files changed

+257
-49
lines changed

Makefile

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# This file is part of workflow-service
2+
# https://github.com/common-workflow-language/workflow-service/, and is
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
18+
# make format to fix most python formatting errors
19+
# make pylint to check Python code for enhanced compliance including naming
20+
# and documentation
21+
# make coverage-report to check coverage of the python scripts by the tests
22+
23+
MODULE1=wes_client
24+
MODULE2=wes_service
25+
PACKAGE=wes-service
26+
EXTRAS=
27+
28+
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
29+
# `[[` conditional expressions.
30+
PYSOURCES=$(shell find $(MODULE1) -name "*.py") $(shell find $(MODULE2) -name "*.py")\
31+
$(wildcard test/*.py) $(wildcard *.py)
32+
DEVPKGS=build diff_cover pylint pep257 pydocstyle 'tox<4' tox-pyenv \
33+
wheel autoflake pyupgrade bandit auto-walrus \
34+
-rlint-requirements.txt -rtest-requirements.txt -rmypy-requirements.txt
35+
DEBDEVPKGS=pep8 python-autopep8 pylint python-coverage pydocstyle sloccount \
36+
python-flake8 python-mock shellcheck
37+
VERSION=v$(shell grep version pyproject.toml | awk -F\" '{print $2}')
38+
mkfile_dir := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
39+
UNAME_S=$(shell uname -s)
40+
41+
## all : default task (install wes-service in dev mode)
42+
all: dev
43+
44+
## help : print this help message and exit
45+
help: Makefile
46+
@sed -n 's/^##//p' $<
47+
48+
## cleanup : shortcut for "make sort_imports format flake8 diff_pydocstyle_report"
49+
cleanup: sort_imports format flake8 diff_pydocstyle_report
50+
51+
## install-dep : install most of the development dependencies via pip
52+
install-dep: install-dependencies
53+
54+
install-dependencies:
55+
pip install -U pip setuptools wheel
56+
pip install --upgrade $(DEVPKGS)
57+
58+
## install-deb-dep : install many of the dev dependencies via apt-get
59+
install-deb-dep:
60+
sudo apt-get install $(DEBDEVPKGS)
61+
62+
## install : install the wes-service package and the scripts
63+
install: FORCE
64+
pip install .$(EXTRAS)
65+
66+
## dev : install the wes-service package in dev mode
67+
dev: install-dep
68+
pip install -U pip setuptools wheel
69+
pip install -e .$(EXTRAS)
70+
71+
## dist : create a module package for distribution
72+
dist: dist/${MODULE}-$(VERSION).tar.gz
73+
74+
dist/${MODULE}-$(VERSION).tar.gz: $(SOURCES)
75+
python -m build
76+
77+
## clean : clean up all temporary / machine-generated files
78+
clean: FORCE
79+
rm -f ${MODULE}/*.pyc tests/*.pyc
80+
rm -Rf .coverage
81+
rm -f diff-cover.html
82+
83+
# Linting and code style related targets
84+
## sort_import : sorting imports using isort: https://github.com/timothycrosley/isort
85+
sort_imports: $(PYSOURCES)
86+
isort $^
87+
88+
remove_unused_imports: $(PYSOURCES)
89+
autoflake --in-place --remove-all-unused-imports $^
90+
91+
pep257: pydocstyle
92+
## pydocstyle : check Python docstring style
93+
pydocstyle: $(PYSOURCES)
94+
pydocstyle --add-ignore=D100,D101,D102,D103 $^ || true
95+
96+
pydocstyle_report.txt: $(PYSOURCES)
97+
pydocstyle $^ > $@ 2>&1 || true
98+
99+
## diff_pydocstyle_report : check Python docstring style for changed files only
100+
diff_pydocstyle_report: pydocstyle_report.txt
101+
diff-quality --compare-branch=main --violations=pydocstyle --fail-under=100 $^
102+
103+
## codespell : check for common misspellings
104+
codespell:
105+
codespell -w $(shell git ls-files | grep -v mypy-stubs)
106+
107+
## format : check/fix all code indentation and formatting (runs black)
108+
format: $(PYSOURCES) FORCE
109+
black $(PYSOURCES)
110+
111+
format-check: $(PYSOURCES)
112+
black --diff --check $^
113+
114+
## pylint : run static code analysis on Python code
115+
pylint: $(PYSOURCES)
116+
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
117+
$^ -j0|| true
118+
119+
pylint_report.txt: $(PYSOURCES)
120+
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
121+
$^ -j0> $@ || true
122+
123+
diff_pylint_report: pylint_report.txt
124+
diff-quality --compare-branch=main --violations=pylint pylint_report.txt
125+
126+
.coverage: testcov
127+
128+
coverage: .coverage
129+
coverage report
130+
131+
coverage.xml: .coverage
132+
coverage xml
133+
134+
coverage.html: htmlcov/index.html
135+
136+
htmlcov/index.html: .coverage
137+
coverage html
138+
@echo Test coverage of the Python code is now in htmlcov/index.html
139+
140+
coverage-report: .coverage
141+
coverage report
142+
143+
diff-cover: coverage.xml
144+
diff-cover --compare-branch=main $^
145+
146+
diff-cover.html: coverage.xml
147+
diff-cover --compare-branch=main $^ --html-report $@
148+
149+
## test : run the wes-service test suite
150+
test: $(PYSOURCES)
151+
python -m pytest -rsx ${PYTEST_EXTRA}
152+
153+
## testcov : run the wes-service test suite and collect coverage
154+
testcov: $(PYSOURCES)
155+
pytest --cov ${PYTEST_EXTRA}
156+
157+
sloccount.sc: $(PYSOURCES) Makefile
158+
sloccount --duplicates --wide --details $^ > $@
159+
160+
## sloccount : count lines of code
161+
sloccount: $(PYSOURCES) Makefile
162+
sloccount $^
163+
164+
list-author-emails:
165+
@echo 'name, E-Mail Address'
166+
@git log --format='%aN,%aE' | sort -u | grep -v 'root'
167+
168+
mypy3: mypy
169+
mypy: ${PYSOURCES}
170+
MYPYPATH=$$MYPYPATH:mypy-stubs mypy $^
171+
172+
shellcheck: FORCE
173+
shellcheck release-test.sh
174+
175+
pyupgrade: $(PYSOURCES)
176+
pyupgrade --exit-zero-even-if-changed --py38-plus $^
177+
auto-walrus $^
178+
179+
release-test: FORCE
180+
git diff-index --quiet HEAD -- || ( echo You have uncommitted changes, please commit them and try again; false )
181+
./release-test.sh
182+
183+
release: release-test
184+
. testenv2/bin/activate && \
185+
pip install build && \
186+
python -m build testenv2/src/${PACKAGE} && \
187+
pip install twine && \
188+
twine upload testenv2/src/${PACKAGE}/dist/* && \
189+
git tag ${VERSION} && git push --tags
190+
191+
flake8: $(PYSOURCES)
192+
flake8 $^
193+
194+
FORCE:
195+
196+
# Use this to print the value of a Makefile variable
197+
# Example `make print-VERSION`
198+
# From https://www.cmcrossroads.com/article/printing-value-makefile-variable
199+
print-% : ; @echo $* = $($*)

cwl_flask.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
from flask import Flask, Response, request, redirect
2-
import subprocess
3-
import tempfile
1+
import copy
42
import json
5-
import yaml
63
import signal
4+
import subprocess
5+
import tempfile
76
import threading
87
import time
9-
import copy
8+
9+
import yaml
10+
from flask import Flask, Response, redirect, request
1011

1112
app = Flask(__name__)
1213

cwltool_stream.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env python
22

3+
import json
4+
import logging
35
import sys
4-
import cwltool.main
56
import tempfile
6-
import logging
7+
8+
import cwltool.main
79
import StringIO
8-
import json
910

1011
_logger = logging.getLogger("cwltool")
1112
_logger.setLevel(logging.ERROR)

test/test_client_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import unittest
2-
import os
31
import logging
2+
import os
43
import subprocess
54
import sys
5+
import unittest
66

77
pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) # noqa
88
sys.path.insert(0, pkg_root) # noqa

test/test_integration.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import unittest
2-
import time
1+
import logging
32
import os
4-
import subprocess
5-
import signal
63
import shutil
7-
import logging
4+
import signal
5+
import subprocess
86
import sys
9-
import requests
7+
import time
8+
import unittest
9+
1010
import pytest
11+
import requests
1112

1213
pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) # noqa
1314
sys.path.insert(0, pkg_root) # noqa

wes_client/util.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import os
1+
import glob
22
import json
3+
import logging
4+
import os
5+
from subprocess import DEVNULL, CalledProcessError, check_call
6+
from urllib.request import pathname2url, urlopen
7+
8+
import requests
39
import schema_salad.ref_resolver
4-
from subprocess import check_call, DEVNULL, CalledProcessError
510
import yaml
6-
import glob
7-
import requests
8-
import logging
911

1012
from wes_service.util import visit
1113

12-
from urllib.request import urlopen, pathname2url
13-
1414

1515
def two_seven_compatible(filePath):
1616
"""Determines if a python file is 2.7 compatible by seeing if it compiles in a subprocess"""

wes_client/wes_client_main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/bin/env python
2-
import pkg_resources # part of setuptools
3-
import json
4-
import time
5-
import sys
6-
import os
72
import argparse
3+
import json
84
import logging
5+
import os
6+
import sys
7+
import time
8+
9+
import pkg_resources # part of setuptools
910
import requests
1011
from requests.exceptions import InvalidSchema, MissingSchema
11-
from wes_client.util import modify_jsonyaml_paths, WESClient
12+
13+
from wes_client.util import WESClient, modify_jsonyaml_paths
1214

1315

1416
def main(argv=sys.argv[1:]):

wes_service/arvados_wes.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import arvados
2-
import arvados.util
3-
import arvados.collection
4-
import arvados.errors
5-
import os
6-
import connexion
1+
import functools
72
import json
3+
import logging
4+
import os
5+
import shutil
86
import subprocess
97
import tempfile
10-
import functools
118
import threading
12-
import logging
13-
import shutil
149

15-
from wes_service.util import visit, WESBackend
10+
import arvados
11+
import arvados.collection
12+
import arvados.errors
13+
import arvados.util
14+
import connexion
15+
16+
from wes_service.util import WESBackend, visit
1617

1718

1819
class MissingAuthorization(Exception):

wes_service/cwl_runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ def GetServiceInfo(self):
161161
[runner, "--version"], stderr=subprocess.PIPE
162162
).communicate()
163163
r = {
164-
"workflow_type_versions": {"CWL": {"workflow_type_version": ["v1.0", "v1.1", "v1.2"]}},
164+
"workflow_type_versions": {
165+
"CWL": {"workflow_type_version": ["v1.0", "v1.1", "v1.2"]}
166+
},
165167
"supported_wes_versions": ["0.3.0", "1.0.0"],
166168
"supported_filesystem_protocols": ["file", "http", "https"],
167169
"workflow_engine_versions": {"cwl-runner": str(stderr)},

wes_service/toil_wes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import json
2+
import logging
23
import os
4+
import shutil
35
import subprocess
46
import time
5-
import logging
67
import uuid
7-
import shutil
8-
98
from multiprocessing import Process
9+
1010
from wes_service.util import WESBackend
1111

1212
logging.basicConfig(level=logging.INFO)

0 commit comments

Comments
 (0)