Skip to content

Commit

Permalink
docs: continued with tutorials and add new classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Miksus committed Nov 24, 2021
1 parent fe3b500 commit 186cf20
Show file tree
Hide file tree
Showing 34 changed files with 953 additions and 428 deletions.
8 changes: 6 additions & 2 deletions docs/condition_syntax/dependence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
Task Dependence
---------------

- ``after task '<task>'``
- ``after task '<task>' [succeeded | failed | finished | terminated]``
**Syntax**

.. code-block:: none
after task '<task>'
after task '<task>' [succeeded | failed | finished | terminated]
**True when**

Expand Down
8 changes: 5 additions & 3 deletions docs/condition_syntax/execution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ Execution on fixed time interval

**Syntax**

- ``[hourly | daily | weekly | monthly]``
- ``[hourly | daily | weekly | monthly] between <start> and <end>``
- ``[hourly | daily | weekly | monthly] [before | after | starting] <time>``
.. code-block:: none
[hourly | daily | weekly | monthly]
[hourly | daily | weekly | monthly] between <start> and <end>
[hourly | daily | weekly | monthly] [before | after | starting] <time>
**True when**

Expand Down
6 changes: 4 additions & 2 deletions docs/condition_syntax/fixed_interval.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ Fixed time interval

**Syntax**

- ``time of [hour | day | week | month] between <start> and <end>``
- ``time of [hour | day | week | month] [after | before] <time>``
.. code-block:: none
time of [hour | day | week | month] between <start> and <end>
time of [hour | day | week | month] [after | before] <time>
**True when**

Expand Down
40 changes: 20 additions & 20 deletions docs/condition_syntax/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,9 @@
Condition Syntax
================

This section lists the condition syntax that are
This section lists the pre-built condition syntax that are
allowed to be passed as strings to ``start_cond``
of a task.

Explanations of the syntax notation:

- ``<start>``, ``<end>`` and ``<time>``

- if "hour", use format mm:ss, ie. ``30:00`` (half past)
- if "day", use 24 hour clock, ie. ``14:00`` (2 PM)
- if "week", supply weekdays as full names or abbreviations, ie. ``Monday`` or ``Mon``
- if "month", supply a day of month, ie. ``13th`` (13th of month)

- ``<timedelta>``

- Supply timedelta as sting, ie. ``1 days, 30 min``. See `pandas.Timedelta <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_.

- ``<task>``

- Supply a name of a task. The task can be created later but should be created before inspecting the status of the condition.
or ``end_cond`` of a task.

.. note::

Expand All @@ -40,4 +23,21 @@ Explanations of the syntax notation:
fixed_interval
timedelta
task_status
dependence
dependence

Explanations of the syntax notation:

- ``<start>``, ``<end>`` and ``<time>``

- if "hour", use format mm:ss, ie. ``30:00`` (half past)
- if "day", use 24 hour clock, ie. ``14:00`` (2 PM)
- if "week", supply weekdays as full names or abbreviations, ie. ``Monday`` or ``Mon``
- if "month", supply a day of month, ie. ``13th`` (13th of month)

- ``<timedelta>``

- Supply timedelta as sting, ie. ``1 days, 30 min``. See `pandas.Timedelta <https://pandas.pydata.org/docs/reference/api/pandas.Timedelta.html>`_.

- ``<task>``

- Supply a name of a task. The task can be created later but should be created before inspecting the status of the condition.
10 changes: 7 additions & 3 deletions docs/condition_syntax/task_status.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
Task Status
-----------

- ``has [succeeded | failed | finished | started | terminated] [this hour | today | this week | this month] between <start> and <end>``
- ``has [succeeded | failed | finished | started | terminated] [this hour | today | this week | this month] [before | after] <time>``
- ``has [succeeded | failed | finished | started | terminated] past <timedelta>``
**Syntax**

.. code-block:: none
has [succeeded | failed | finished | started | terminated] [this hour | today | this week | this month] between <start> and <end>
has [succeeded | failed | finished | started | terminated] [this hour | today | this week | this month] [before | after] <time>
has [succeeded | failed | finished | started | terminated] past <timedelta>
**True when**

Expand Down
4 changes: 3 additions & 1 deletion docs/condition_syntax/timedelta.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Timedelta

**Syntax**

- ``every <timedelta>``
.. code-block:: none
every <timedelta>
**True when**

Expand Down
8 changes: 8 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Contributing
============

All help is welcome. If you found a bug or have ideas or suggestions,
please create an issue in `Red Engine Github page <https://github.com/Miksus/red-engine>`_.
Also pull requests are welcome.

21 changes: 8 additions & 13 deletions docs/examples/session/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,28 @@
from redengine import Session
from redengine.tasks import FuncTask

# Session
# -------

session = Session(
scheme=["log_memory"] # Logging to memory
)

# Tasks
# -----

@FuncTask(start_cond="minutely")
@FuncTask(start_cond="daily")
def my_task_1():
# Runs once a minute
# Runs once a day
...

@FuncTask(start_cond="daily")
@FuncTask(start_cond="every 10 min 20 sec")
def my_task_2():
# Runs once a day
# Runs once every 10 minutes and 20 seconds
...

@FuncTask(start_cond="after task 'my_task_2'")
@FuncTask(start_cond="after task 'my_task_1' & after task 'my_task_2'")
def my_task_3():
# Runs after "my_task_2" succeeded
# Runs after "my_task_1" and "my_task_2" succeeded
...


# Starting up
# -----------
if __name__ == "__main__":
session.start()
session.start()
# Blocked till interupted
44 changes: 44 additions & 0 deletions docs/how_it_works.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@


How it works?
=============

There are three core components in Red Engine's ecosystem:

- **Session**: handles the configuration and act as an interface
- **Scheduler**: handles the flow of the system
- **Task**: handles how to execute a task


Flow of the system
------------------

.. figure:: scheduling.png
:figwidth: 1000
:alt: system flow


Task execution
--------------

.. figure:: task_execution.png
:figwidth: 1000
:alt: task execution

Additional components
---------------------

There are also some components that don't define the
flow of the system but are still important for the
system to function or essential for many of the
features:

- **Condition**: A statement that is true or false but the
outcome may be dependent on time.
- **Parameters**: A container (dict) for key-value pairs
passed to tasks.
- **Argument**: A value of a key-value pair in Parameters.
Useful for providing dynamics to the parametrization.
- **TimePeriod**: An abstraction of time elements to define
time intervals and periods such as *today*, *specific time of day*,
*week* etc.
36 changes: 20 additions & 16 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

Too lazy to read? :ref:`Get started then. <getting-started>`

Red Engine is an open source Python scheduling library made for
humans. It is suitable for scrapers, data processes,
process automatization or IOT applications. It also
has minimal dependencies and is pure Python.
Red Engine is an open source advanced scheduling library made for
Python. It is suitable for automating processes, scheduling web scrapers,
and building IOT applications. It also has minimal amount of dependencies
and is pure Python.

Visit the `source code from Github <https://github.com/Miksus/red-engine>`_
or `releases in Pypi page <https://pypi.org/project/redengine/>`_.
Expand All @@ -22,27 +22,28 @@ or `releases in Pypi page <https://pypi.org/project/redengine/>`_.
Why :red:`Red` Engine?
----------------------

Red Engine's focus is on productivity: minimizing the
boiler plate, maximizing readability extendability.
Creating and scheduling tasks are very easy to do.
Red Engine's focus is on readability, productivity and extendability.
The philosophy behind the library is that simple things should be simple
and easy and complex things should be done by combining simple things.
The ultimate focus is in you: the library aims to make your life easier.

:red:`Red` Engine is useful for small to moderate size
projects. It is, however, not meant to handle thousands
of tasks or execute tasks with the percision required
by, for example, modern game engines.
by, for example, game engines.

Core Features
-------------

- **Easy setup:** Use a premade setup and focus on building your project.
- **Condition parsing:** Scheduling tasks can be done with human readable statements.
- **Parametrization:** Tasks consume session specific or task specific parameters depending on what they need.
- **Extendability:** Almost everything is made for customization. Even the tasks can modify the scheduler.
- **Condition syntax:** Scheduling tasks can be done with human readable statements.
- **Parametrization:** Tasks can be parameterized various ways or they can be pipelined.
- **Extendability:** Almost everything is made for customization. Even the tasks can modify the flow of the system.

:red:`Red` Engine has built-in scheduling syntax which
allows logical operations to create complex scheduling logic
with breeze. Also, it very easy to extend and create your
own conditions.
with breeze. Also, it very easy to create your own conditions
for your needs.

Example
-------
Expand All @@ -56,14 +57,15 @@ This is all it takes to create a scheduler:
But does it work?
-----------------

The system is tested with over 900 unit tests to
The system is tested with over 1000 unit tests to
ensure quality and to deliver what is promised.
Red Engine is used in production.

Interested?
-----------

There is much more to offer. Read more and try it yourself.
There is much more to offer. Start from the
:ref:`short guide <short-guide>`.


.. toctree::
Expand All @@ -75,7 +77,9 @@ There is much more to offer. Read more and try it yourself.
condition_syntax/index
reference/index
examples/index

how_it_works
contributing
versions


Indices and tables
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Arguments

.. autoclass:: redengine.arguments.Arg

.. autoclass:: redengine.arguments.Return

.. testsetup:: funcarg

from redengine import session
Expand All @@ -21,4 +23,3 @@ Arguments
session.clear()

.. autoclass:: redengine.arguments.Private

7 changes: 7 additions & 0 deletions docs/reference/baseclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ Task

.. autoclass:: redengine.core.Task
:members:
:exclude-members: return_arg

Condition
---------

.. autoclass:: redengine.core.BaseCondition
:members:

Parameters
----------

.. autoclass:: redengine.core.Parameters
:members:

Argument
--------

Expand Down
3 changes: 3 additions & 0 deletions docs/reference/conditions.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Conditions
==========

.. autoclass:: redengine.conditions.FuncCond

.. autoclass:: redengine.conditions.TaskCond

Task related conditions
-----------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
API References of Red Engine
============================
API References
==============

You can find the references to the
Red Engine's classes here.
Expand Down
Binary file added docs/scheduling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/task_execution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 186cf20

Please sign in to comment.