Package: zrb
🫰 Installation|📖 Documentation|🏁 Getting Started|💃 Common Mistakes|❓ FAQ🤖 Zrb: A Framework to Enhance Your WorkflowZrb is aCLI-basedautomationtoolandlow-codeplatform. Zrb can help you to:Automateday-to-day tasks.Generateprojects or applications.Prepare,run, anddeployyour applications with a single command.Etc.You can also write custom task definitions inPython, enhancing Zrb's base capabilities. Defining your tasks in Zrb gives you several advantages because:Every task has aretry mechanism.Zrb handles yourtask dependenciesautomatically.Zrb runs your task dependenciesconcurrently.🫰 Installing ZrbYou can install Zrb as a pip package by invoking the following command:pipinstallzrbAlternatively, you can also use our installation script to install Zrb along with some prerequisites:source<(curl-shttps://raw.githubusercontent.com/state-alchemists/zrb/main/install.sh)Check ourinstallation guidefor more information about the installation methods, including installation as a docker container.⚙️ Zrb as A Task-Automation ToolAt the very core, Zrb is a task automation tool. It helps you to automate some tedious jobs so that you can focus on what matters.Let's say you want to be able to describe the statistics property of any public CSV dataset. To do this, you need to perform three tasks like the following:Install pandas.Download the CSV dataset (at the same time).Show statistics properties of the CSV dataset.🐼
Install Pandas ─────┐           📊
                    ├──► Show Statistics
Download Datasets ──┘
       ⬇️You can create a file namedzrb_init.pyand define the tasks as follows:# File name: zrb_init.pyfromzrbimportrunner,Parallel,CmdTask,python_task,StrInputDEFAULT_URL='https://raw.githubusercontent.com/state-alchemists/datasets/main/iris.csv'# 🐼 Define a task named `install-pandas` to install pandas.# If this task failed, we want Zrb to retry it again 4 times at most.install_pandas=CmdTask(name='install-pandas',cmd='pip install pandas',retry=4)# ⬇️ Define a task named `download-dataset` to download dataset.# This task has an input named `url`.# The input will be accessible by using Jinja template: `{{input.url}}`# If this task failed, we want Zrb to retry it again 4 times at mostdownload_dataset=CmdTask(name='download-dataset',inputs=[StrInput(name='url',default=DEFAULT_URL)],cmd='wget -O dataset.csv {{input.url}}',retry=4)# 📊 Define a task named `show-stat` to show the statistics properties of the dataset.# @python_task` decorator turns a function into a Zrb Task (i.e., `show_stat` is now a Zrb Task).# If this task failed, we don't want to retry@python_task(name='show-stats',retry=0)defshow_stats(*args,**kwargs):importpandasaspddf=pd.read_csv('dataset.csv')returndf.describe()# Define dependencies: `show_stat` depends on both, `download_dataset` and `install_pandas`Parallel(download_dataset,install_pandas)>>show_stats# Register the tasks so that they are accessbie from the CLIrunner.register(install_pandas,download_dataset,show_stats)📝 NOTE:It is possible (although less readable) to defineshow_statasCmdTask:Show codeshow_stats=CmdTask(name='show-stats',cmd='python -c "import pandas as pd; df=pd.read_csv(\'dataset.csv\'); print(df.describe())"',retry=0)Once you write the definitions, Zrb will automatically load yourzrb_init.pyso that you can invoke your registered task:zrbshow-statThe command will give you the statistics property of the dataset:sepal_length  sepal_width  petal_length  petal_width
count    150.000000   150.000000    150.000000   150.000000
mean       5.843333     3.054000      3.758667     1.198667
std        0.828066     0.433594      1.764420     0.763161
min        4.300000     2.000000      1.000000     0.100000
25%        5.100000     2.800000      1.600000     0.300000
50%        5.800000     3.000000      4.350000     1.300000
75%        6.400000     3.300000      5.100000     1.800000
max        7.900000     4.400000      6.900000     2.500000See the full outputUrl [https://raw.githubusercontent.com/state-alchemists/datasets/main/iris.csv]:
🤖 ○ ◷ ❁ 43598 → 1/3 🐮 zrb project install-pandas • Run script: pip install pandas
🤖 ○ ◷ ❁ 43598 → 1/3 🐮 zrb project install-pandas • Working directory: /home/gofrendi/playground/my-project
🤖 ○ ◷ ❁ 43598 → 1/3 🍓 zrb project download-dataset • Run script: wget -O dataset.csv https://raw.githubusercontent.com/state-alchemists/datasets/main/iris.csv
🤖 ○ ◷ ❁ 43598 → 1/3 🍓 zrb project download-dataset • Working directory: /home/gofrendi/playground/my-project
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • --2023-11-12 09:45:12--  https://raw.githubusercontent.com/state-alchemists/datasets/main/iris.csv
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.109.133, 185.199.110.133, ...
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • HTTP request sent, awaiting response... 200 OK
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • Length: 4606 (4.5K) [text/plain]
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • Saving to: ‘dataset.csv’
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset •
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset •      0K ....                                                  100% 1.39M=0.003s
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset •
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset • 2023-11-12 09:45:12 (1.39 MB/s) - ‘dataset.csv’ saved [4606/4606]
🤖 △ ◷ ❁ 43603 → 1/3 🍓 zrb project download-dataset •
🤖 ○ ◷ ❁ 43601 → 1/3 🐮 zrb project install-pandas • Requirement already satisfied: pandas in /home/gofrendi/zrb/.venv/lib/python3.10/site-packages (2.1.3)
🤖 ○ ◷ ❁ 43601 → 1/3 🐮 zrb project install-pandas • Requirement already satisfied: numpy<2,>=1.22.4 in /home/gofrendi/zrb/.venv/lib/python3.10/site-packages (from pandas) (1.26.1)
🤖 ○ ◷ ❁ 43601 → 1/3 🐮 zrb project install-pandas • Requirement already satisfied: python-dateutil>=2.8.2 in /home/gofrendi/zrb/.venv/lib/python3.10/site-packages (from pandas) (2.8.2)
🤖 ○ ◷ ❁ 43601 → 1/3 🐮 zrb project install-pandas • Requirement already satisfied: pytz>=2020.1 in /home/gofrendi/zrb/.venv/lib/python3.10/site-packages (from pandas) (2023.3.post1)
🤖 ○ ◷ ❁ 43601 → 1/3 🐮 zrb project install-pandas • Requirement already satisfied: tzdata>=2022.1 in /home/gofrendi/zrb/.venv/lib/python3.10/site-packages (from pandas) (2023.3)
🤖 ○ ◷ ❁ 43601 → 1/3 🐮 zrb project install-pandas • Requirement already satisfied: six>=1.5 in /home/gofrendi/zrb/.venv/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Support zrb growth and development!
☕ Donate at: https://stalchmst.com/donation
🐙 Submit issues/PR at: https://github.com/state-alchemists/zrb
🐤 Follow us at: https://twitter.com/zarubastalchmst
🤖 ○ ◷ 2023-11-12 09:45:14.366 ❁ 43598 → 1/3 🍎 zrb project show-stats • Completed in 2.2365798950195312 seconds
       sepal_length  sepal_width  petal_length  petal_width
count    150.000000   150.000000    150.000000   150.000000
mean       5.843333     3.054000      3.758667     1.198667
std        0.828066     0.433594      1.764420     0.763161
min        4.300000     2.000000      1.000000     0.100000
25%        5.100000     2.800000      1.600000     0.300000
50%        5.800000     3.000000      4.350000     1.300000
75%        6.400000     3.300000      5.100000     1.800000
max        7.900000     4.400000      6.900000     2.500000
To run again: zrb project show-stats --url "https://raw.githubusercontent.com/state-alchemists/datasets/main/iris.csv"Since you have registeredinstall_pandasanddownload_dataset(i.e.,runner.register(install_pandas, download_dataset)), then you can also execute those tasks as well:zrbinstall-pandas
zrbdownload-dataset📝 NOTE:When executing a task, you can also provide the parameter directly, for example you want to provide theurlzrbshow-stat--urlhttps://raw.githubusercontent.com/state-alchemists/datasets/main/iris.csvWhen you provide the parameter directly, Zrb will not prompt you to supply the URL.
Another way to disable the prompt is by setZRB_SHOW_PROMPTto0orfalse.You can also run a Docker compose file, start a Web server, generate a CRUD application, or set up multiple servers simultaneously.Seeour getting started guideandtutorialsto learn more about the details.✂️ Zrb as A Low-Code FrameworkZrb has some built-in tasks that allow you to create and run aCRUDapplication.Let's see the following example.# Create a projectzrbprojectcreate--project-dirmy-project--project-name"My Project"cdmy-project# Create a Fastappzrbprojectaddfastapp--project-dir.--app-name"fastapp"--http-port3000# Add library module to fastappzrbprojectaddfastapp-module--project-dir.--app-name"fastapp"--module-name"library"# Add entity named "books"zrbprojectaddfastapp-crud--project-dir.--app-name"fastapp"--module-name"library"\--entity-name"book"--plural-entity-name"books"--column-name"code"# Add column to the entityzrbprojectaddfastapp-field--project-dir.--app-name"fastapp"--module-name"library"\--entity-name"book"--column-name"title"--column-type"str"# Run Fastapp as monolithzrbprojectstart-fastapp--fastapp-run-mode"monolith"Once you invoke the commands, you will be able to access the CRUD application by pointing your browser tohttp://localhost:3000Furthermore, you can also split your application intomicroservices, run them asdocker containers, and even deploy them to yourkubernetes cluster.# Run Fastapp as microserviceszrbprojectstart-fastapp--fastapp-run-mode"microservices"# Run Fastapp as containerzrbprojectstart-fastapp-container--fastapp-run-mode"microservices"zrbprojectstop-fastapp-container# Deploy fastapp and all it's dependencies to kubernetesdockerlogin
zrbprojectdeploy-fastapp--fastapp-deploy-mode"microservices"Visitour tutorialsto see more cool tricks.📖 Documentation🫰 Installation🏁 Getting Started📖 Documentation💃 Common Mistakes❓ FAQ🐞 Bug Report + Feature RequestYou can submit bug report and feature request by creating a newissueon Zrb Github Repositories. When reporting a bug or requesting a feature, please be sure to:Include the version of Zrb you are using (i.e.,zrb version)Tell us what you have tryTell us what you expectTell us what you getWe will also welcome yourpull requests and contributions.☕ DonationHelp Red Skull to click the donation button:🎉 Fun FactMadou Ring Zaruba (魔導輪ザルバ, Madōrin Zaruba) is a Madougu which supports bearers of the Garo Armor.(Garo Wiki | Fandom)🙇 CreditsWe are thankful for the following libraries and services. They accelerate Zrb development processes and make things more fun.LibrariesBeartype: Catch invalid typing earlier during runtime.Click: Creating a beautiful CLI interface.Termcolor: Make the terminal interface more colorful.Jinja: A robust templating engine.Ruamel.yaml: Parse YAML effortlessly.Jsons: Parse JSON. This package should be part of the standard library.Libcst: Turn Python code into a Concrete Syntax Tree.Croniter: Parse cron pattern.Flit,Twine, and many more. See the complete list of Zrb's requirements.txtServicesasciiflow.com: Creates beautiful ASCII-based diagrams.emojipedia.org: Find emoji.emoji.aranja.com: Turns emoji into imagesfavicon.io: Turns pictures and texts (including emoji) into favicon.