Skip to content

Commit

Permalink
actionpack#89: "cleanup" (#103)
Browse files Browse the repository at this point in the history
* removes repl chars from READ examples

* updates supported python versions in setup.py

* declares actionpack as beta
  • Loading branch information
withtwoemms authored Jan 21, 2022
1 parent 2a67e13 commit c3878b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ Sometimes `ActionType`s in a `Pipeline` don't "fit" together.
That's where the `Pipeline.Fitting` comes in:

```python
>>> listen = ReadInput('What should I record? ')
>>> record = Pipeline.Fitting(
... action=Write,
... **{
... 'prefix': f'[{datetime.now()}] ',
... 'append': True,
... 'filename': filename,
... 'to_write': Pipeline.Receiver
... },
... )
>>> Pipeline(listen, record).perform()
listen = ReadInput('What should I record? ')
record = Pipeline.Fitting(
action=Write,
**{
'prefix': f'[{datetime.now()}] ',
'append': True,
'filename': filename,
'to_write': Pipeline.Receiver
},
)
Pipeline(listen, record).perform()
```

> ⚠️ **_NOTE:_** Writing to stdout is also possible using the `Write.STDOUT` object as a filename. How that works is an exercise left for the user.
Expand All @@ -63,39 +63,39 @@ That's where the `Pipeline.Fitting` comes in:
An `Action` collection can be used to describe a procedure:

```python
>>> actions = [action,
... Read('path/to/some/other/file'),
... ReadInput('>>> how goes? <<<\n > '),
... MakeRequest('GET', 'http://google.com'),
... RetryPolicy(MakeRequest('GET', 'http://bad-connectivity.com'),
... max_retries=2,
... delay_between_attempts=2)
... Write('path/to/yet/another/file', 'sup')]
...
>>> procedure = Procedure(actions)
actions = [action,
Read('path/to/some/other/file'),
ReadInput('>>> how goes? <<<\n > '),
MakeRequest('GET', 'http://google.com'),
RetryPolicy(MakeRequest('GET', 'http://bad-connectivity.com'),
max_retries=2,
delay_between_attempts=2)
Write('path/to/yet/another/file', 'sup')]

procedure = Procedure(actions)
```

And a `Procedure` can be executed synchronously or otherwise:

```python
>>> results = procedure.execute() # synchronously by default
>>> _results = procedure.execute(synchronously=False) # async; not thread safe
>>> result = next(results)
>>> print(result.value)
results = procedure.execute() # synchronously by default
_results = procedure.execute(synchronously=False) # async; not thread safe
result = next(results)
print(result.value)
```

A `KeyedProcedure` is just a `Procedure` comprised of named `Action`s.
The `Action` names are used as keys for convenient result lookup.

```python
>>> prompt = '>>> sure, I'll save it for ya.. <<<\n > '
>>> saveme = ReadInput(prompt).set(name='saveme')
>>> writeme = Write('path/to/yet/another/file', 'sup').set(name='writeme')
>>> actions = [saveme, writeme]
>>> keyed_procedure = KeyedProcedure(actions)
>>> results = keyed_procedure.execute()
>>> keyed_results = dict(results)
>>> first, second = keyed_results.get('saveme'), keyed_results.get('writeme')
prompt = '>>> sure, I'll save it for ya.. <<<\n > '
saveme = ReadInput(prompt).set(name='saveme')
writeme = Write('path/to/yet/another/file', 'sup').set(name='writeme')
actions = [saveme, writeme]
keyed_procedure = KeyedProcedure(actions)
results = keyed_procedure.execute()
keyed_results = dict(results)
first, second = keyed_results.get('saveme'), keyed_results.get('writeme')
```

> ⚠️ **_NOTE:_** `Procedure` elements are evaluated _independently_ unlike with a `Pipeline` in which the result of performing an `Action` is passed to the next `ActionType`.
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
maintainer_email='[email protected]',
url='https://github.com/withtwoemms/actionpack',
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Science/Research',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
install_requires=[
'OSlash==0.5.1',
Expand Down

0 comments on commit c3878b8

Please sign in to comment.