Skip to main content

Your faithful sidekick

Project description

Zrb (WIP)

Your faithful sidekick

How to install

pip install zrb

How to use

To run a task, you can invoke the following command:

zrb <task> [arguments]

How to define tasks

Zrb will automatically load:

  • zrb_init.py in your current directory.
  • or any Python file defined in ZRB_INIT_SCRIPTS environment.

You can use a colon separator (:) to define multiple scripts in ZRB_INIT_SCRIPTS. For example:

ZRB_SCRIPTS=~/personal/zrb.py:~/work/zrb_init.py

Your Zrb script should contain your task definitions. For example:

from zrb import runner

install_venv = CmdTask(
    name='install_venv',
    inputs=[
        StrInput(name='dir', default='venv', prompt='Venv directory'),
        BooleanInput(
            name='installrequirements', 
            default=True, 
            prompt='Install requirements (y/n)'
        )
    ],
    cmd='''
        pip -m venv {{ input.dir }}
        source {{ input.dir}}/bin/activate
        {% if input.installrequirements %}pip install -r requirements.txt{% endif %}
    '''
)

run_fastapi = CmdProcess(
    name='run_fastapi',
    directory='./fastapi',
    envs=[
        Env(name='PORT', sys_name='FASTAPI_PORT', default='3000')
    ],
    inputs=[
        BooleanInput(name='reload', default=False, prompt='Auto reload (y/n)')
    ],
    upstream=[install_venv],
    cmd='uvicorn main:app {% if input.reload %}--reload{% endif %}',
    check=[
        HttpPortCheck(port='{{env.PORT}}'),
    ]
)

runner.register(install_venv)
runner.register(run_fastapi)

Once you register your tasks, they will be accessible from the terminal:

# Invoke `run-fastapi` and make sure `install-venv` has been already performed
export FASTAPI_PORT=8080
zrb run_fastapi -reload=yes -installrequirements=yes

For contributors

There is a toolkit you can use to test whether Zrb is working as intended.

To use the toolkit, you can invoke the following:

source ./toolkit.sh

# Build Zrb
build-zrb

# Test zrb in playground
prepare-playground
cd playground
source venv/bin/activate
# Start testing/creating use cases...

For maintainers

To publish Zrb, you need a Pypi account:

You can also create a TestPypi account:

Once you have your API token, you need to create a ~/.pypirc file:

[distutils]
index-servers =
   pypi
   testpypi

[pypi]
  repository = https://upload.pypi.org/legacy/
  username = __token__
  password = pypi-xxx-xxx
[testpypi]
  repository = https://test.pypi.org/legacy/
  username = __token__
  password = pypi-xxx-xxx

To publish Zrb, you can do the following:

source ./toolkit.sh

# Build Zrb
build-zrb

# Publish Zrb to TestPypi
test-publish-zrb

# Publish Zrb to Pypi
publish-zrb

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zrb-0.0.3.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

zrb-0.0.3-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file zrb-0.0.3.tar.gz.

File metadata

  • Download URL: zrb-0.0.3.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for zrb-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b729a5c80dc0ee568a8ca8c75f7a9833a757bcee6f4ea49119af486d658ad837
MD5 4233ea3c1a9de20e0203a84f52c91584
BLAKE2b-256 52bc2b8082387a48c4077ba97f4d93f2d6b18fcdec42d9aeda7fe5cb84630307

See more details on using hashes here.

File details

Details for the file zrb-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: zrb-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for zrb-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a892e157e9e354f490f1948edc3768e007648ae9520d83b1d4a06c1bc59c370e
MD5 e6598ef797cc044d8743a320a6b162ce
BLAKE2b-256 572580f2717f05ba058fa8bf15176961a76c71b60f60657c62fbd1758e14093a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page