Skip to main content

PyAuto Core

Project description

A task running tool

What is this?

PyAuto provides a minimalist project structure for capturing configuration and orchestrating tasks.

What is a Task?

A python function.

# deployment_tasks.py

# this needs to be imported so that the config class will be registered
import deployment_config


def deploy_app(config, app_name):
    # implement deployment here
    print('deploying {0}...'.format(app_name))
    app = config.apps.get_tag(app_name)
    print(app)

How is it configured?

YAML + Python Class.

# config.yml
task_modules:
- deployment_tasks
apps:
- id: my_app
  name: My Application
  source_dir: ./my_app
tasks:
  deploy_my_app:
  - deploy_app,my_app
# deployment_config.py

from pyauto import config
import os


class App(config.Config):
    def get_source_dir(self):
        return os.path.abspath(self.source_dir)


config.set_config_class('apps', App.wrap)

How is it used?

As a CLI tool.

Run the task

$ python -m pyauto.deploy -c config.yml deploy,my_app

Outputs

----- deployment_tasks.deploy_app ( my_app  ) -----
deploying my_app...
OrderedDict([('id', 'my_app'), ('name', 'My Application'), ('source_dir', './my_app')])
deploy_app,my_app = None

The “,” separates the function from the string arguments. All task functions must accept string only arguments.

Run a sequence of tasks

$ python -m pyauto.deploy -c config.yml deploy_my_app

Outputs

----- deployment_tasks.deploy_app ( my_app  ) -----
deploying my_app...
OrderedDict([('id', 'my_app'), ('name', 'My Application'), ('source_dir', './my_app')])
deploy_app,my_app = None

Line 1 of the output indicates the function invoked, with the arguments passed to it. Lines 2-3 of the output indicate the standard output of the function’s execution Last line of the output indicates 1) the original function invocation string and 2) the return value of the function.

If you wish to suppress output of line 1 and last line, you can pass the -q option to have PyAuto omit those lines.

The task sequence deploy_my_app is looked up from the tasks section of the config. A task sequence may list as many tasks or task sequences as desired. Every item will always be executed when the task sequence is invoked.

Dry-run a sequence of tasks

$ python -m pyauto.deploy -c config.yml deploy_my_app -i

Outputs

deploy_my_app (  )
    deployment_tasks.deploy_app ( my_app )

This shows the sequence of tasks that will be run. This is a trivial example, but you may also invoke other task sequences from a task sequence, which can lead to a complex order of tasks. This feature allows you to inspect what a given task sequence will execute before you execute it.

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

pyauto.core-0.2.0.tar.gz (20.8 kB view details)

Uploaded Source

File details

Details for the file pyauto.core-0.2.0.tar.gz.

File metadata

  • Download URL: pyauto.core-0.2.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyauto.core-0.2.0.tar.gz
Algorithm Hash digest
SHA256 15865dcd06fd62fcc451ae2e7c57525047859a994c7bf4bf4927923ac134e259
MD5 029a5b52ad0948306f0cdd11e4317352
BLAKE2b-256 20db6ed9c4106c34f482f8f6a3428e2da877a125bd4782e8baa8b5f0c76448ba

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