Automatey is a lightweight Python library designed to simplify the management of configurations and the execution of tasks as a Directed Acyclic Graph (DAG). It provides robust configuration handling, flexible logging, and utility features to streamline automation workflows.
- Configuration Management: Automatically discovers and loads configuration files (
automatey.toml) from the current or parent directories. - Logging: Configurable logging with support for both console and file handlers.
- Singleton Design: Ensures only one instance of the
Automateyclass is created during runtime. - Execution Timer: Tracks and logs the total execution time of your script when it exits.
Automatey is not yet published to PyPI, so you can clone this repository to use it locally:
git clone https://github.com/your-username/automatey.git
cd automateyEnsure you are using Python 3.11 or later, as specified in the .python-version file.
-
Initialize Automatey: Import and create an instance of the
Automateyclass. This will automatically load the configuration file (automatey.toml) and set up logging.from automatey import Automatey auto = Automatey()
-
Access Configuration: Use the
get_configmethod to retrieve values from the loaded configuration.# Example: Access the DAG name from the configuration dag_name = auto.get_config('automatey', 'dag', 'name') print(f"DAG Name: {dag_name}")
-
Logging: Automatey provides a pre-configured logger. Use it to log messages.
auto.logger.info("This is an info log message.") auto.logger.error("This is an error log message.")
-
Execution Timer: Automatey automatically logs the total execution time of your script when it exits.
Automatey expects a TOML configuration file named automatey.toml. Here’s an example configuration:
foo = "bar"
[automatey.dag]
name = "ETL Pipeline"
[[automatey.dag.tasks]]
name = "extract"
depends_on = []
[[automatey.dag.tasks]]
name = "transform"
depends_on = ["extract"]
[[automatey.dag.tasks]]
name = "load"
depends_on = ["transform"]You can customize logging behavior in the automatey.toml file. For example:
[automatey.logging]
enable_file_handler = true
filename = "./Log/automatey_<YYYY><MM><DD>.log"
filemode = "a"
format = "%(asctime)s: %(levelname)s: %(message)s"
datefmt = "%Y-%m-%d %H:%M:%S"
encoding = "utf-8"
level = "INFO"enable_file_handler: Enables logging to a file.filename: Specifies the log file name. You can use placeholders like<YYYY>,<MM>,<DD>,<DATE>, and<TIME>for dynamic filenames.level: Sets the logging level (e.g.,INFO,DEBUG,ERROR).
Here’s a complete example of using Automatey:
from automatey import Automatey
# Initialize Automatey
auto = Automatey()
# Access configuration
dag_name = auto.get_config('automatey', 'dag', 'name')
print(f"DAG Name: {dag_name}")
# Log messages
auto.logger.info("Starting the ETL pipeline...")
auto.logger.info(f"DAG Name: {dag_name}")
auto.logger.info("ETL pipeline completed successfully.")# Updated to specify language as plaintext
plaintext
automatey/
├── LICENSE
├── README.md
├── automatey.toml
├── pyproject.toml
├── src/
│ └── automatey/
│ ├── __init__.py
│ ├── automatey.py
│ ├── cli.py
│ └── ui.py
├── tests/
│ └── test_automatey.py
└── Log/
├── automatey_20250922.log
└── automatey_20250928.log
Automatey includes a basic test file in tests/test_automatey.py. To run the test:
python -m unittest discover tests- Task Execution: Extend Automatey to execute tasks defined in the DAG configuration.
- CLI Support: Implement a command-line interface for managing tasks.
- UI Integration: Build a user interface for visualizing and managing DAGs.
This project is licensed under the MIT License. See the LICENSE file for details.
