Skip to main content

AI job deployment templates with YAML and Jinja2.

Project description

AI Job Deploy

Getting started.

pip install ai-jobdeploy
  1. In a project mkdir .js
  2. Create some deployment templates (see below)
  3. Get experimenting!

Base Template

Templates must implement 5 fields: params, meta, config, values and builds.

params is a list of parameters specified on creation up of the resource. meta is a list and subset of "subdir", "id", "project". config is a dictionary of configured values (e.g. security group ids, etc..) values are a dictionary of formatted values (on the basis of parameters) which are and may be referred to in the builds.

The builds section must implement up and down. There are 3 types of builds:

  • sequence
  • script
  • file

sequence: sequence of scripts or files.

script: an executable script (usually bash).

file: a file saved to the path given by the build name.

local.yaml

params:
  - name
  - run
  
meta:
  - id
  - subdir
  - project

config:
  python: /usr/bin/python3

builds:
  install:
    type: script
    content: |
      #!/bin/bash
      {{ params['python'] }} -m pip install -r requirements.txt

  deploy_script:
    type: file
    content: |
      #!/bin/bash
      mkdir -p checkpoints/{{ params.name }}
      {{ params['run'] }} | tee checkpoints/{{ params.name }}/log

  start:
    type: script
    content: |
      #!/bin/bash
      chmod +x .jd/{{ params['subdir'] }}/tasks/deploy_script
      tmux new-session -d -s {{ params['project'] }}-{{ params['id'] }} ".jd/{{ params['subdir'] }}/tasks/deploy_script"

  watch:
    type: script
    content: |
      #!/bin/bash
      tmux a -t {{ params['project'] }}-{{ params['id'] }}

  down:
    type: script
    whitelist: [256]
    content: |
      #!/bin/bash
      tmux kill-session -t {{ params['project'] }}-{{ params['id'] }}

  purge:
    type: script
    content: |
      #!/bin/bash
      rm -rf checkpoints/{{ params['name'] }}

  up:
    type: sequence
    content:
      - install
      - deploy_script
      - start

Using templates to create and manage resources

List resources:

jd ls

Here is how to create the my_model.yaml resource:

jd build local up --params run='python3 -u test.py',name=test

Do something with the resource (anything apart from up). Get id from jd ls.

jd build watch --id <id>

Stop resource:

jd rm <id> [--purge/--no-purge]

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

ai-jobdeploy-0.0.1.dev19.tar.gz (12.7 kB view details)

Uploaded Source

File details

Details for the file ai-jobdeploy-0.0.1.dev19.tar.gz.

File metadata

  • Download URL: ai-jobdeploy-0.0.1.dev19.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2

File hashes

Hashes for ai-jobdeploy-0.0.1.dev19.tar.gz
Algorithm Hash digest
SHA256 ccd0e92269a0fd1baca633b7beb1aef1886c9f7f6460b7ace9730ef7badfc42a
MD5 34064965f2a4415339a1cc769f35ccde
BLAKE2b-256 9c6b507f73b468fd12a8133606f2589d8b67151b6428df80239318694f1076b6

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