Task execution engine for data management and monitoring
Project description

Avaris Task Engine
Avaris is a modular task execution and data processing engine designed for easy integration and customization for various task executions, with a strong focus on data management tasks.
Notable Features
- Flexible Task Configurations: Manage and customize your tasks with YAML configuration files.
- Modular Design: Easily extend or modify components, supporting dynamic loading of plugins under
.avaris/src. - Asynchronous Support: Built with async capabilities for efficient I/O operations.
- Task Scheduling: Supports different backends, currently only APScheduler.
- Extensible Executors: Execute tasks based on predefined or custom logic.
- Data Management: Introduces
SQLDataManagerfor relational database management, in addition to customizable data managers and handlers for diverse data storage and processing needs.
Installation
# Clone the repository
git clone https://github.com/avyr-io/avaris.git
cd avaris
# Install requirements
python -m pip install poetry
poetry install
python -m avaris start --config config/conf.yml --compendium-dir ./compendium
Getting Started
To run Avaris, you'll need to specify your engine configuration and compendium directory. Here's a quick guide to get you started.
Configuration Files
Avaris requires two main types of configuration files:
- Engine Configuration (
config/conf.yml): Defines global settings for the Avaris avaris.engine. - Compendium Configurations (
./compendium): Each compendium file should have its own configuration file in this directory, detailing tasks, endpoints, and data management settings.
Running Avaris
Usage: avaris start [OPTIONS]
Start the engine with the specified configuration. You must specify either a
compendium directory or a compendium file. Optionally, you can specify a
plugins directory.
Options:
-p, --plugins-dir PATH Path to the directory containing plugin modules.
Defaults to $PWD/.avaris/plugins
-f, --compendium-file PATH Path to a single compendium configuration file.
-d, --compendium-dir PATH Path to the directory containing compendium
configurations.
-c, --config PATH Path to the engine configuration YAML file.
--help Show this message and exit.
python -m avaris start --config config/conf.yml --compendium-dir ./compendium
Replace config/conf.yml and ./compendium with the paths to your actual engine configuration file and compendium configuration directory, respectively.
Examples
Here are some examples of how to use Avaris for different tasks.
Defining a compendium Configuration
# compendium_config.yml
compendium:
- name: PrometheusVersioncompendium
destination: local
tasks:
- name: FetchLatestPrometheusVersion
schedule: "* * * * *"
executor:
task: http_get_github_release
parameters:
api_url: "https://api.github.com/repos/prometheus/prometheus/releases/latest"
- name: FluentBitVersioncompendium
destination: local
tasks:
- name: FetchLatestFluentBitVersion
schedule: "* * * * *"
executor:
task: http_get_github_release
parameters:
api_url: "https://api.github.com/repos/fluent/fluent-bit/releases/latest"
Custom Task Executor
Implementing a custom task executor involves creating a Python class that inherits from TaskExecutor and defines the execute method.
# ./my_avaris.executor.py
from avaris.executor.executor import TaskExecutor
from avaris.api.models import BaseParameter
from avaris.task.task_registry import register_task_executor
class MyExecutorParameters(BaseParameter):
__NAME__ = 'my_exec_identifier'
# Define parameters here
@register_task_executor(MyExecutorParameters)
class MyExecutor(TaskExecutor[MyExecutorParameters]):
async def execute(self) -> dict:
# Implementation of your task
try:
return {}
except Exception as e:
self.logger.error(f"An error occurred while executing task: {e}")
raise
Passing variables from the environment
For a task parameter set that looks like this
class HTTPGetParameters(BaseParameter):
__NAME__ = 'http_get'
url: str
username: Optional[str] = None
password: Optional[SecretStr] = None
response_format: Literal['json', 'text',
'binary'] = 'text'
You can now instruct Avaris to get the secret from the environment directly like so.
compendium:
name: get request
tasks:
- name: get example.com
schedule: "* * * * *"
executor:
task: http_get
parameters:
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}
url: https://example.com
response_format: text
Another way to specify secrets (legacy method) would be like so:
from avaris.executor.executor import TaskExecutor
from avaris.api.models import BaseParameter
from avaris.task.task_registry import register_task_executor
"""Define your parameter model with its identifier"""
class MyParameters(BaseParameter):
__NAME__ = 'my_task_identifier_in_yaml'
my_param: str = ""
@register_task_executor(MyParameters)
class MyTask(TaskExecutor[MyParameters]) :
async def execute(self) -> dict:
try:
self.logger.info("Hello World!")
# Fetch secrets if any were mentioned explicity from the config. (will also load from env)
secrets = await self.load_secrets()
access_parameters_this_way = self.parameters.my_param
my_secret = secrets.get("MY_SECRET", None)
return {'my_key': self.parameters.my_param}
except Exception as e:
self.logger.error(
f"Error : {e}")
return {'error': str(e)}
And then in YAML you could instruct Avaris this way:
compendium:
name: latest version jobs
tasks:
- # more tasks...
- name: Example
schedule: "* * * * *"
executor:
task: my_task_identifier_in_yaml # task identifier
parameters:
my_param: "123"
secrets:
MY_SECRET: # implicity loading from env
Default Configurations Summary
Directories
- Home Directory:
~/.avaris - Working Directory:
$WORKINGDIRor fallback to~/.avarisor current working directory - Data Directory:
$DATAor~/.avaris/data - Plugins Directory:
~/.avarisor$WORKINGDIR/.avaris - Compendium Directory:
$COMPENDIUMor~/.avaris/compendiumor$WORKINGDIR/compendium
Files
- Configuration File:
$CONFIGorconf.yamlin several locations - SQLite Database:
~/.avaris/data/local.db - Log File:
$LOGSoravaris.login several locations
Secrets
- Listener Key:
$LISTENER_KEY
Default Configuration
- YAML Configuration:
# defined per src/avaris/defaults.py
execution_backend: apscheduler
data_backend:
backend: sqlite
database_url: # empty defaults to local.db
services:
datasource:
enabled: true
port: 5000
How To Contribute
Contributions to Avaris are welcome. Please refer to the CONTRIBUTING.md file for guidelines on how to make contributions.
License
Avaris is released under the Apache 2.0 License. See the LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file avaris-0.2.3.tar.gz.
File metadata
- Download URL: avaris-0.2.3.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.8.18 Linux/6.5.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83a7c51cee70fceb20a53df4611c3dd77ac1c779d3dc0d6f55fdd91eaf482658
|
|
| MD5 |
ab2471e30223b85fc565e0ae916c42c1
|
|
| BLAKE2b-256 |
34af86a75e3f62b8627e2275a9b643ffff8f71ba78afae8694346a359db87ad7
|
File details
Details for the file avaris-0.2.3-py3-none-any.whl.
File metadata
- Download URL: avaris-0.2.3-py3-none-any.whl
- Upload date:
- Size: 47.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.8.18 Linux/6.5.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77e5063372bc0cc9828e811563b2019438f109da7e6cf6895a9814f06f52ac05
|
|
| MD5 |
b299f12440ff0fe021c04a0c0396c96e
|
|
| BLAKE2b-256 |
232b65f6d35d2ee31919a89d845b6e013272339a59762c171593a4c38db97507
|