-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use ordered data structure to keep track of queue processes (#7) * Fix potential sync bugs with processes being joined out of order * A dictionary is unordered, this could cause issues when joining processes since this operation needs to be done in order * Using a tuple is the best option here, since it is immutable and the structure is simple enough * push rolling releases with rc branch, not develop * Create 0.0.2rc (#8) * Use ordered data structure to keep track of queue processes (#7) * Fix potential sync bugs with processes being joined out of order * A dictionary is unordered, this could cause issues when joining processes since this operation needs to be done in order * Using a tuple is the best option here, since it is immutable and the structure is simple enough * push rolling releases with rc branch, not develop * bump package version to 0.0.2rc * add mypy configuration file * I decided to start using mypy to typecheck the library * supress flake8 errors in init * improve inner library organization * Move the contents of main.py to automator.py so the naming was clearer * Also move the example outside the src folder of the library as it is not library code * Add support to insert data to a queue other than the initial one * Fix bug in the validate_non_empty_args helper * add a reset() api to clear the QueueAutomator state * Create MultiprocessMaybe * This multiprocessing helper uses the Maybe pattern as inspiration to chain several function calls using multiprocessing * It wraps a QueueAutomator instance and provides a different style API which could be cleaner than having a bunch of decorators and manually defining queue names. * This is a work in progress, and it is improving with every iteration * Add example for MultiprocessingMaybe * Showcase the MultiprocessingMaybe capabilities in an example -> insert to intermediate queues -> replace None or values matching a predicate with the default value -> Prevent crashes for None values not executing the function when the input matches a predicate * Add tests for QueueAutomator * Include the first round of tests for the queue automator, this will ensure that the main functionality does not break if changed * Update mypy configurations * This is to exclude build and dist directories from typechecking * Add docstrings to MultiprocessMaybe * Update rc version * Update Readme * Include Multiprocessing maybe examples * Update package version to publish
- Loading branch information
Showing
10 changed files
with
438 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from time import perf_counter, sleep | ||
|
||
from queue_automator.maybe import MultiprocessMaybe | ||
|
||
import logging | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
|
||
def do_work(item: int) -> int: | ||
sleep(2) | ||
result = item*2 | ||
print(f'{item} times two {result}') | ||
return result | ||
|
||
|
||
def do_work_2(item: int) -> int: | ||
sleep(2) | ||
result = item**2 | ||
print(f'{item} squared {result}') | ||
return result | ||
|
||
|
||
def do_work_3(item: int) -> int: | ||
sleep(2) | ||
result = item**3 | ||
print(f'{item} cubed {result}') | ||
return result | ||
|
||
|
||
if __name__ == '__main__': | ||
start = perf_counter() | ||
result = MultiprocessMaybe() \ | ||
.insert(range(10)) \ | ||
.then(do_work) \ | ||
.insert(range(10, 20)) \ | ||
.then(do_work_2) \ | ||
.insert(range(20, 30)) \ | ||
.maybe(do_work_3, default=0) | ||
|
||
end = perf_counter() | ||
|
||
print(result) | ||
print(f'Took {end-start:0.2f}s') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[mypy] | ||
exclude = ['.venv', 'build', 'dist'] | ||
disallow_untyped_defs = True | ||
disallow_untyped_calls = True | ||
disallow_untyped_decorators = False | ||
no_implicit_optional = True | ||
warn_redundant_casts = True | ||
warn_unreachable = True | ||
ignore_missing_imports = True | ||
ignore_missing_imports_per_module = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setuptools.setup( | ||
name="queue-automator", | ||
version="0.0.2", | ||
version="0.1.0", | ||
author="Wason1797", | ||
author_email="[email protected]", | ||
description="A simple wrapper to build queue multiprocessing pipelines", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .main import QueueAutomator | ||
# flake8: noqa | ||
from .automator import QueueAutomator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.