Skip to content

Commit

Permalink
precommit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Feb 6, 2021
1 parent f23b21f commit adfbf56
Show file tree
Hide file tree
Showing 38 changed files with 316 additions and 16 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/on_push.yml
Expand Up @@ -3,6 +3,21 @@ on: push
jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [ 3.7, 3.8 ]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@master
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements/requirements_dev.txt
pip install -r requirements/requirements_docs.txt
- uses: cnheider/postdoc@master

11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
@@ -1,6 +1,15 @@
fail_fast: true
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.7
language_version: python3.7
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
2 changes: 2 additions & 0 deletions benchmarks/benchmark_func.py
Expand Up @@ -7,6 +7,8 @@


def benchmark_func(func, times=100000):
"""
"""
start = time.time()
result = None
for _ in range(times):
Expand Down
14 changes: 14 additions & 0 deletions benchmarks/pqp_benchmark.py
Expand Up @@ -7,6 +7,8 @@

class Zeroes(PooledQueueTask):
def call(self, batch_size, *args, tensor_size=(9, 9, 9, 9), **kwargs):
"""
"""
batch = [(numpy.zeros(tensor_size), i) for i in range(batch_size)]
imgs = numpy.array([i[0] for i in batch], dtype=numpy.float32)
ground_truth = numpy.array([i[1] for i in batch], dtype=numpy.float32)
Expand All @@ -17,10 +19,14 @@ def call(self, batch_size, *args, tensor_size=(9, 9, 9, 9), **kwargs):


def Func(a, tensor_size):
"""
"""
return f"{a, tensor_size}"


def pqp_benchmark():
"""
"""
task = Zeroes()
# task = Lamb #Error: cant be pickled
# task = Func
Expand All @@ -37,16 +43,24 @@ def pqp_benchmark():
)

def get():
"""
"""
return df.get()

def wait_get():
"""
"""
time.sleep(wait_time)
return df.get()

def generate():
"""
"""
return task(batch_size, tensor_size=tensor_size)

def wait_generate():
"""
"""
time.sleep(wait_time)
return task(batch_size, tensor_size=tensor_size)

Expand Down
18 changes: 18 additions & 0 deletions benchmarks/returns_benchmark.py
Expand Up @@ -6,34 +6,52 @@


def returns_benchmark():
"""
"""
a = 1
b = 2
c = 3

RandomABC = namedtuple("RandomABC", ("a", "b", "c"))

def implicit_return():
"""
"""
return a, b, c

def list_return():
"""
"""
return [a, b, c]

def tuple_return():
"""
"""
return (a, b, c)

def dict_return():
"""
"""
return {"a": a, "b": b, "c": c}

def sorcery_return():
"""
"""
return sorcery.dict_of(a, b, c)

def nod_return():
"""
"""
return NOD(a=a, b=b, c=c)

def inferred_return():
"""
"""
return NOD.nod_of(a, b, c)

def namedtuple_return():
"""
"""
return RandomABC(a, b, c)

for func in (
Expand Down
4 changes: 4 additions & 0 deletions docs/source/conf.py
Expand Up @@ -217,10 +217,14 @@


def patched_make_field(self, types, domain, items, **kw):
"""
"""
# `kw` catches `env=None` needed for newer sphinx while maintaining
# backwards compatibility when passed along further down!
# #type: (List, unicode, Tuple) -> nodes.field
def handle_item(fieldarg, content):
"""
"""
par = nodes.paragraph()
par += addnodes.literal_strong("", fieldarg) # Patch: this line added
# par.extend(self.make_xrefs(self.rolename, domain, fieldarg,
Expand Down
5 changes: 5 additions & 0 deletions pytest.ini
@@ -0,0 +1,5 @@
[pytest]
addopts = --ignore=exclude --ignore-glob=*exclude*

#[pycodestyle]
#ignore = not_me_* ALL
4 changes: 4 additions & 0 deletions samples/config_samples/async_test/addition_config_usage.py
Expand Up @@ -9,6 +9,8 @@


async def b():
"""
"""
import config2

print(config2.A_CONSTANT)
Expand All @@ -17,6 +19,8 @@ async def b():
if __name__ == "__main__":

async def c():
"""
"""
await b()

import asyncio
Expand Down
2 changes: 2 additions & 0 deletions samples/config_samples/async_test/reimport_config_stest.py
Expand Up @@ -10,6 +10,8 @@
if __name__ == "__main__":

async def a():
"""
"""
import addition_config_usage

await addition_config_usage.b()
Expand Down
2 changes: 2 additions & 0 deletions samples/config_samples/multiprocessing_stes.py
Expand Up @@ -11,6 +11,8 @@


def f(x):
"""
"""
import config1

print(config1.A_CONSTANT)
Expand Down
2 changes: 2 additions & 0 deletions samples/config_samples/regular_stes.py
Expand Up @@ -10,6 +10,8 @@
if __name__ == "__main__":

def f():
"""
"""
import config1

print(config1.A_CONSTANT)
Expand Down
8 changes: 8 additions & 0 deletions samples/queues/parallel_env_sampling.py
Expand Up @@ -13,22 +13,30 @@


def worker(input, output):
"""
"""
for func, args in iter(input.get, "STOP"):
result = calculate(func, args)
output.put(result)


def calculate(func, args):
"""
"""
result = func(*args)
return f"{current_process().name} says that {func.__name__}{args} = {result}"


def mul(a, b):
"""
"""
time.sleep(0.5 * random.random())
return a * b


def plus(a, b):
"""
"""
time.sleep(0.5 * random.random())
return a + b

Expand Down

0 comments on commit adfbf56

Please sign in to comment.