Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit a9dece5

Browse files
John Andersenpdxjohnny
authored andcommitted
style: Correct style of all submodules
* Enforce style in all submodules via ci Fixes: #173 Signed-off-by: John Andersen <john.s.andersen@intel.com>
1 parent 95995be commit a9dece5

21 files changed

Lines changed: 541 additions & 572 deletions

File tree

.ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function run_whitespace() {
7777
}
7878

7979
function run_style() {
80-
black --check dffml tests examples
80+
black --check .
8181
}
8282

8383
if [ "x$PLUGIN" != "x" ]; then

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4949
- DNNClassifierModel no longer splits data for the user.
5050
- Update `pip` in Dockerfile.
5151
- Restructured documentation
52+
- Ran `black` on whole codebase, including all submodules
53+
- CI style check now checks whole codebase
5254
### Fixed
5355
- Docs get version from dffml.version.VERSION.
5456
- FileSource zipfiles are wrapped with TextIOWrapper because CSVSource expects

feature/auth/dffml_feature_auth/feature/definitions.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
from dffml.df.base import Definition
44

55
definitions = [
6-
Definition(
7-
name="UnhashedPassword",
8-
primitive="string",
9-
),
10-
Definition(
11-
name="ScryptPassword",
12-
primitive="string",
13-
)
6+
Definition(name="UnhashedPassword", primitive="string"),
7+
Definition(name="ScryptPassword", primitive="string"),
148
]
159

1610
for definition in definitions:
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: MIT
22
# Copyright (c) 2019 Intel Corporation
3-
'''Logging'''
3+
"""Logging"""
44
import logging
5+
56
LOGGER = logging.getLogger(__package__)

feature/auth/dffml_feature_auth/feature/operations.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@
55
from typing import Dict, Any
66

77
from dffml.df.types import Operation
8-
from dffml.df.base import OperationImplementationContext, \
9-
OperationImplementation
8+
from dffml.df.base import (
9+
OperationImplementationContext,
10+
OperationImplementation,
11+
)
1012

1113
# pylint: disable=no-name-in-module
12-
from .definitions import UnhashedPassword, \
13-
ScryptPassword
14+
from .definitions import UnhashedPassword, ScryptPassword
1415

1516
scrypt = Operation(
16-
name='scrypt',
17-
inputs={
18-
'password': UnhashedPassword,
19-
},
20-
outputs={
21-
'password': ScryptPassword
22-
},
23-
conditions=[])
17+
name="scrypt",
18+
inputs={"password": UnhashedPassword},
19+
outputs={"password": ScryptPassword},
20+
conditions=[],
21+
)
2422

25-
class ScryptContext(OperationImplementationContext):
2623

24+
class ScryptContext(OperationImplementationContext):
2725
@staticmethod
2826
def hash_password(password):
2927
# ---- BEGIN Python hashlib docs ----
@@ -69,7 +67,7 @@ def hash_password(password):
6967

7068
# ---- END RFC 7914 ----
7169

72-
password = password.encode('utf-8')
70+
password = password.encode("utf-8")
7371

7472
salt = os.urandom(16 * 4)
7573
n = 2 ** 10
@@ -89,13 +87,10 @@ async def run(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
8987
# we submit to the thread pool. Weird behavior can happen if we raise in
9088
# there.
9189
hashed_password, salt = await self.parent.loop.run_in_executor(
92-
self.parent.pool, self.hash_password, inputs['password'])
93-
return {
94-
'password': {
95-
'hashed': hashed_password,
96-
'salt': salt,
97-
}
98-
}
90+
self.parent.pool, self.hash_password, inputs["password"]
91+
)
92+
return {"password": {"hashed": hashed_password, "salt": salt}}
93+
9994

10095
class Scrypt(OperationImplementation):
10196

@@ -108,7 +103,7 @@ def __init__(self, *args, **kwargs):
108103
self.pool = None
109104
self.__pool = None
110105

111-
async def __aenter__(self) -> 'OperationImplementationContext':
106+
async def __aenter__(self) -> "OperationImplementationContext":
112107
self.loop = asyncio.get_event_loop()
113108
# ProcessPoolExecutor is slightly faster but deprecated and will be
114109
# removed in 3.9
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '0.0.1'
1+
VERSION = "0.0.1"

feature/auth/setup.py

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,50 @@
66

77
self_path = os.path.dirname(os.path.realpath(__file__))
88

9-
with open(os.path.join(self_path, 'dffml_feature_auth', 'version.py'),
10-
'r') as f:
9+
with open(
10+
os.path.join(self_path, "dffml_feature_auth", "version.py"), "r"
11+
) as f:
1112
for line in f:
12-
if line.startswith('VERSION'):
13-
version = ast.literal_eval(line.strip().split('=')[-1].strip())
13+
if line.startswith("VERSION"):
14+
version = ast.literal_eval(line.strip().split("=")[-1].strip())
1415
break
1516

16-
with open(os.path.join(self_path, 'README.md'), 'r', encoding='utf-8') as f:
17+
with open(os.path.join(self_path, "README.md"), "r", encoding="utf-8") as f:
1718
readme = f.read()
1819

19-
INSTALL_REQUIRES = [
20-
]
20+
INSTALL_REQUIRES = []
2121

2222
setup(
23-
name='dffml_feature_auth',
23+
name="dffml_feature_auth",
2424
version=version,
25-
description='',
25+
description="",
2626
long_description=readme,
27-
long_description_content_type='text/markdown',
28-
author='John Andersen',
29-
author_email='john.s.andersen@intel.com',
30-
url='https://github.com/intel/dffml/blob/master/feature/auth/README.md',
31-
license='MIT',
32-
33-
keywords=[
34-
'',
35-
],
36-
27+
long_description_content_type="text/markdown",
28+
author="John Andersen",
29+
author_email="john.s.andersen@intel.com",
30+
url="https://github.com/intel/dffml/blob/master/feature/auth/README.md",
31+
license="MIT",
32+
keywords=[""],
3733
classifiers=[
38-
'Development Status :: 3 - Alpha',
39-
'Intended Audience :: Developers',
40-
'License :: OSI Approved :: MIT License',
41-
'License :: OSI Approved :: Apache Software License',
42-
'Natural Language :: English',
43-
'Operating System :: OS Independent',
44-
'Programming Language :: Python :: 3.7',
45-
'Programming Language :: Python :: Implementation :: CPython',
46-
'Programming Language :: Python :: Implementation :: PyPy',
34+
"Development Status :: 3 - Alpha",
35+
"Intended Audience :: Developers",
36+
"License :: OSI Approved :: MIT License",
37+
"License :: OSI Approved :: Apache Software License",
38+
"Natural Language :: English",
39+
"Operating System :: OS Independent",
40+
"Programming Language :: Python :: 3.7",
41+
"Programming Language :: Python :: Implementation :: CPython",
42+
"Programming Language :: Python :: Implementation :: PyPy",
4743
],
48-
4944
install_requires=INSTALL_REQUIRES,
5045
tests_require=[],
51-
5246
packages=find_packages(),
5347
entry_points={
54-
'dffml.operation': [
55-
'scrypt = dffml_feature_auth.feature.operations:scrypt',
48+
"dffml.operation": [
49+
"scrypt = dffml_feature_auth.feature.operations:scrypt"
5650
],
57-
'dffml.operation.implementation': [
58-
'scrypt = dffml_feature_auth.feature.operations:Scrypt',
51+
"dffml.operation.implementation": [
52+
"scrypt = dffml_feature_auth.feature.operations:Scrypt"
5953
],
6054
},
6155
)

feature/auth/tests/test_df.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import random
22

33
from dffml.df.types import Operation, Input
4-
from dffml.df.base import BaseConfig, \
5-
StringInputSetContext
6-
from dffml.df.memory import MemoryOrchestrator, \
7-
MemoryInputSet, \
8-
MemoryInputSetConfig
4+
from dffml.df.base import BaseConfig, StringInputSetContext
5+
from dffml.df.memory import (
6+
MemoryOrchestrator,
7+
MemoryInputSet,
8+
MemoryInputSetConfig,
9+
)
910

1011
from dffml.operation.output import GetSingle
1112
from dffml.util.asynctestcase import AsyncTestCase
@@ -15,25 +16,30 @@
1516
OPIMPS = [Scrypt, GetSingle.imp]
1617
OPERATIONS = [Scrypt.op, GetSingle.imp.op]
1718

18-
class TestRunner(AsyncTestCase):
1919

20+
class TestRunner(AsyncTestCase):
2021
async def test_run(self):
21-
passwords = [
22-
str(random.random()) for _ in range(0, 20)
23-
]
22+
passwords = [str(random.random()) for _ in range(0, 20)]
2423

2524
# Orchestrate the running of these operations
2625
async with MemoryOrchestrator.basic_config(*OPIMPS) as orchestrator:
2726

2827
definitions = Operation.definitions(*OPERATIONS)
2928

30-
passwords = [Input(value=password,
31-
definition=definitions['UnhashedPassword'],
32-
parents=None) for password in passwords]
29+
passwords = [
30+
Input(
31+
value=password,
32+
definition=definitions["UnhashedPassword"],
33+
parents=None,
34+
)
35+
for password in passwords
36+
]
3337

34-
output_spec = Input(value=['ScryptPassword'],
35-
definition=definitions['get_single_spec'],
36-
parents=None)
38+
output_spec = Input(
39+
value=["ScryptPassword"],
40+
definition=definitions["get_single_spec"],
41+
parents=None,
42+
)
3743

3844
async with orchestrator() as octx:
3945
# Add our inputs to the input network with the context being the URL
@@ -42,15 +48,18 @@ async def test_run(self):
4248
MemoryInputSet(
4349
MemoryInputSetConfig(
4450
ctx=StringInputSetContext(password.value),
45-
inputs=[password, output_spec]
51+
inputs=[password, output_spec],
4652
)
4753
)
4854
)
4955
try:
50-
async for _ctx, results in octx.run_operations(strict=True):
56+
async for _ctx, results in octx.run_operations(
57+
strict=True
58+
):
5159
self.assertTrue(results)
5260
except AttributeError as error:
53-
if "module 'hashlib' has no attribute 'scrypt'" \
54-
in str(error):
61+
if "module 'hashlib' has no attribute 'scrypt'" in str(
62+
error
63+
):
5564
return
5665
raise

feature/git/dffml_feature_git/feature/definitions.py

Lines changed: 22 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,31 @@
33
from dffml.df.base import Definition
44

55
definitions = [
6-
Definition(
7-
name="quarter_start_date",
8-
primitive="int"
9-
),
10-
Definition(
11-
name="quarter",
12-
primitive="int",
13-
),
14-
Definition(
15-
name="URL",
16-
primitive="string",
17-
),
18-
Definition(
19-
name="valid_git_repository_URL",
20-
primitive="boolean",
21-
),
22-
Definition(
23-
name="git_branch",
24-
primitive="str",
25-
),
26-
Definition(
27-
name="git_repository",
28-
primitive="Dict[str, str]",
29-
lock=True
30-
),
6+
Definition(name="quarter_start_date", primitive="int"),
7+
Definition(name="quarter", primitive="int"),
8+
Definition(name="URL", primitive="string"),
9+
Definition(name="valid_git_repository_URL", primitive="boolean"),
10+
Definition(name="git_branch", primitive="str"),
11+
Definition(name="git_repository", primitive="Dict[str, str]", lock=True),
3112
Definition(
3213
name="git_repository_checked_out",
3314
primitive="Dict[str, str]",
34-
lock=True
35-
),
36-
Definition(
37-
name="git_commit",
38-
primitive="string"
39-
),
40-
Definition(
41-
name="date",
42-
primitive="string"
43-
),
44-
Definition(
45-
name="no_git_branch_given",
46-
primitive="boolean"
47-
),
48-
Definition(
49-
name="date_pair",
50-
primitive="List[date]"
51-
),
52-
Definition(
53-
name="author_line_count",
54-
primitive="Dict[str, int]"
55-
),
56-
Definition(
57-
name="work_spread",
58-
primitive="int"
59-
),
60-
Definition(
61-
name="release_within_period",
62-
primitive="bool"
63-
),
64-
Definition(
65-
name="lines_by_language_count",
66-
primitive="Dict[str, Dict[str, int]]"
67-
),
68-
Definition(
69-
name="language_to_comment_ratio",
70-
primitive="int"
71-
),
72-
Definition(
73-
name="commit_count",
74-
primitive="int"
75-
),
76-
Definition(
77-
name="author_count",
78-
primitive="int"
79-
),
80-
Definition(
81-
name="date_generator_spec",
82-
primitive="Dict[str, Any]"
83-
)
15+
lock=True,
16+
),
17+
Definition(name="git_commit", primitive="string"),
18+
Definition(name="date", primitive="string"),
19+
Definition(name="no_git_branch_given", primitive="boolean"),
20+
Definition(name="date_pair", primitive="List[date]"),
21+
Definition(name="author_line_count", primitive="Dict[str, int]"),
22+
Definition(name="work_spread", primitive="int"),
23+
Definition(name="release_within_period", primitive="bool"),
24+
Definition(
25+
name="lines_by_language_count", primitive="Dict[str, Dict[str, int]]"
26+
),
27+
Definition(name="language_to_comment_ratio", primitive="int"),
28+
Definition(name="commit_count", primitive="int"),
29+
Definition(name="author_count", primitive="int"),
30+
Definition(name="date_generator_spec", primitive="Dict[str, Any]"),
8431
]
8532

8633
for definition in definitions:
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
'''Logging'''
1+
"""Logging"""
22
import logging
3+
34
LOGGER = logging.getLogger(__package__)

0 commit comments

Comments
 (0)