Skip to content

Commit

Permalink
Merge pull request #112 from lucafaggianelli/dev
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
lucafaggianelli authored May 22, 2023
2 parents 04ec172 + ee5d280 commit 6864770
Show file tree
Hide file tree
Showing 80 changed files with 662 additions and 979 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest
permissions:
# this permission is mandatory for PyPI trusted publishing
id-token: write

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- uses: actions/setup-node@v3
with:
cache-dependency-path: frontend/yarn.lock
node-version: 18
cache: 'yarn'

- name: Install frontend dependencies
working-directory: frontend
run: yarn

- name: Build frontend
working-directory: frontend
run: yarn build

- name: Install py dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,7 @@ cython_debug/
#.idea/

node_modules
/src/plombery/static/*
!/src/plombery/static/.gitkeep

.DS_Store
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
recursive-include mario/static *
recursive-include src/plombery/static *
include README.md
204 changes: 42 additions & 162 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,31 @@
<!-- PROJECT LOGO -->
<br />
<div align="center">
<h3 align="center">Mario Pype</h3>
<h3 align="center">Plombery</h3>

<p align="center">
Python task scheduler with a user-friendly web UI
<br />
<a href="https://lucafaggianelli.github.io/mario-pype/"><strong>Official website »</strong></a>
<a href="https://lucafaggianelli.github.io/plombery/"><strong>Official website »</strong></a>
<br />
<br />
<a href="https://github.com/lucafaggianelli/mario-pype/issues">Report Bug</a>
<a href="https://github.com/lucafaggianelli/plombery/issues">Report Bug</a>
·
<a href="https://github.com/lucafaggianelli/mario-pype/issues">Request Feature</a>
<a href="https://github.com/lucafaggianelli/plombery/issues">Request Feature</a>
</p>
</div>


<!-- ABOUT THE PROJECT -->
## About The Project

Mario Pype is a simple task scheduler for Python with a web UI and a REST API,
Plombery is a simple task scheduler for Python with a web UI and a REST API,
if you need to run and monitor recurring python scripts then it's
the right tool for you!

![Mario Pype Screen Shot](docs/assets/images/screenshot.png)
<figure>
<img src="docs/assets/images/screenshot.png" alt="Plombery Screen Shot">
</figure>

> This project is at its beginning, so it can be shaped and improved with
your feedback and help!
Expand Down Expand Up @@ -75,163 +77,30 @@ When you shouldn't use it:

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- GETTING STARTED -->
## Getting Started

Check the 👉 [official website](https://lucafaggianelli.github.io/mario-pype/)
for more detailed info!

### Prerequisites

To run Mario Pype you only need Python (v3.8 or later), if you don't have it installed yet, go
to the [official Python website](https://www.python.org/downloads/), download it
and install it.

### Installation

Create and activate a virtual enrivonment in your new project folder,
for example:

```sh
python -m venv .venv
# on Mac/Linux
source .venv/bin/activate
# on Win
.venv/Script/activate
```

Then install the library:

> Mario Pype is not published yet on pypi.org, that's why you need to install it
from git!

```sh
pip install git+https://github.com/lucafaggianelli/mario-pype
```

Now you're ready to get started! Create a new folder in your project root with
a file named `app.py` (or any name you want) in it,
as in Python files should be in a top-level package.

<p align="right">(<a href="#readme-top">back to top</a>)</p>


### Create your first Pipeline

*Pipelines* are entities that can be scheduled and are composed of 1 or multiple *Tasks*.

A Pipeline is a Python class that contains a list of tasks and eventually a list of triggers,
so in your `app.py` add this:

```py
from datetime import datetime
from random import randint

from apscheduler.triggers.interval import IntervalTrigger
from mario import Mario, task, get_logger, Pipeline, Trigger


sales_pipeline = Pipeline(
id="sales_pipeline",
tasks = [fetch_raw_sales_data],
triggers = [
Trigger(
id="daily",
name="Daily",
description="Run the pipeline every day",
aps_trigger=IntervalTrigger(days=1),
)
],
)
```

A *Task* is the base block in Mario Pype and it's just a Python function that
performs an action.

This is the Task `fetch_raw_sales_data` used in the `sales_pipeline` pipeline ... it doesn't do much,
but it showcase the basics:

```py
@task
async def fetch_raw_sales_data(input_data, params=None):
logger = get_logger()

logger.debug("Fetching sales data...")

sales = [
{
"price": randint(1, 1000),
"store_id": randint(1, 10),
"date": datetime.today(),
"sku": randint(1, 50),
}
for _ in range(50)
]

logger.info("Fetched %s sales data rows", len(sales))

return sales
```

Finally create a MarioPype instance and register the pipeline so
Mario knows it's there:

```py
app = Mario()

app.register_pipeline(dummy_pipeline)
```

### Run Mario Pype
## 🚀 Getting Started

Mario Pype is based on FastAPI so you can run it as a normal FastAPI app via `uvicorn`:
Check the 👉 [official website](https://lucafaggianelli.github.io/plombery/)

```sh
uvicorn my_project.app:app --reload
```
## 🧐 Show me the code

Now open the page http://localhost:8000 in your browser and enjoy!

### Usage from the UI

From the home page at http://localhost:8000 hit the button *Run pipeline*
then click *Run* in the dialog.

Now close the dialog and click on the pipeline name, then find the run on the right
and click on its number to view the details

### Configure notifications

You can optionally configure notifications creating the file `mario.config.yaml`
in the project root:

```yml
notifications:
- pipeline_status:
- failed
- completed
channels:
- mailto://myuser:[email protected]
```
You can have multiple notifications configs and multiple channels for each config.
The channel is a URI directly passed to the notifications engine
[Apprise](https://github.com/caronc/apprise), check their docs for the supported channels.
This is how it looks a minimalist pipeline:

<figure>
<img src="docs/assets/images/minimal-code.png" alt="Minimal code">
<figcaption>I know you want to see it!</figcaption>
</figure>

<!-- ROADMAP -->
## Roadmap
## 🛣 Roadmap

See the [open issues](https://github.com/lucafaggianelli/mario-pype/issues) for a full list of proposed features (and known issues).
See the [open issues](https://github.com/lucafaggianelli/plombery/issues) for a full list of proposed features (and known issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p>


<!-- CONTRIBUTING -->
## Contributing
## 👩‍💻 Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

Expand Down Expand Up @@ -291,6 +160,17 @@ run the development server:
yarn dev
```

### Documentation

The documentation website is based on MkDocs Material, the source code is in the
`docs/` folder and the config is in the `mkdocs.yml` file.

To run a local dev server, run:

```
mkdocs serve
```

### Testing

Tests are based on `pytest`, to run the entire suite just run:
Expand Down Expand Up @@ -318,7 +198,7 @@ Distributed under the MIT License. See `LICENSE.txt` for more information.
<!-- CONTACT -->
## Contact

Project Link: [https://github.com/lucafaggianelli/mario-pype](https://github.com/lucafaggianelli/mario-pype)
Project Link: [https://github.com/lucafaggianelli/plombery](https://github.com/lucafaggianelli/plombery)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand All @@ -327,7 +207,7 @@ Project Link: [https://github.com/lucafaggianelli/mario-pype](https://github.com
<!-- ACKNOWLEDGMENTS -->
## Acknowledgments

Mario Pype is built on top of amazing techs:
Plombery is built on top of amazing techs:

* [FastAPI](https://fastapi.tiangolo.com/)
* [Pydantic](https://docs.pydantic.dev/)
Expand All @@ -343,16 +223,16 @@ Mario Pype is built on top of amazing techs:

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/lucafaggianelli/mario-pype.svg?style=for-the-badge
[contributors-url]: https://github.com/lucafaggianelli/mario-pype/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/lucafaggianelli/mario-pype.svg?style=for-the-badge
[forks-url]: https://github.com/lucafaggianelli/mario-pype/network/members
[stars-shield]: https://img.shields.io/github/stars/lucafaggianelli/mario-pype.svg?style=for-the-badge
[stars-url]: https://github.com/lucafaggianelli/mario-pype/stargazers
[issues-shield]: https://img.shields.io/github/issues/lucafaggianelli/mario-pype.svg?style=for-the-badge
[issues-url]: https://github.com/lucafaggianelli/mario-pype/issues
[license-shield]: https://img.shields.io/github/license/lucafaggianelli/mario-pype.svg?style=for-the-badge
[license-url]: https://github.com/lucafaggianelli/mario-pype/blob/master/LICENSE
[contributors-shield]: https://img.shields.io/github/contributors/lucafaggianelli/plombery.svg?style=for-the-badge
[contributors-url]: https://github.com/lucafaggianelli/plombery/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/lucafaggianelli/plombery.svg?style=for-the-badge
[forks-url]: https://github.com/lucafaggianelli/plombery/network/members
[stars-shield]: https://img.shields.io/github/stars/lucafaggianelli/plombery.svg?style=for-the-badge
[stars-url]: https://github.com/lucafaggianelli/plombery/stargazers
[issues-shield]: https://img.shields.io/github/issues/lucafaggianelli/plombery.svg?style=for-the-badge
[issues-url]: https://github.com/lucafaggianelli/plombery/issues
[license-shield]: https://img.shields.io/github/license/lucafaggianelli/plombery.svg?style=for-the-badge
[license-url]: https://github.com/lucafaggianelli/plombery/blob/master/LICENSE
[product-screenshot]: images/screenshot.png
[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
[Next-url]: https://nextjs.org/
Expand Down
24 changes: 24 additions & 0 deletions docs/a-better-pipeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@


```py
register_pipeline(
id="sales_pipeline",
description="""This is a very useless pipeline""",
tasks=[get_sales_data],
triggers=[
Trigger(
id="daily",
name="Daily",
description="Run the pipeline every day",
params=InputParams(some_value=2),
schedule=IntervalTrigger(
days=1,
start_date=datetime(
2023, 1, 1, 22, 30, tzinfo=tz.gettz("Europe/Brussels")
),
),
)
],
params=InputParams,
)
```
Binary file added docs/assets/images/minimal-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/assets/images/run-pipeline-button.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/assets/images/run-pipeline-dialog.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/assets/images/run-trigger-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 6864770

Please sign in to comment.