Polyaxon exposes several types for defining inputs and outputs. Some of these types are composite types, this section outlines the definition of the composite types.

possible types

* ANY: "any"
* INT: "int"
* FLOAT: "float"
* BOOL: "bool"
* STR: "str"
* DICT: "dict"
* DICT_OF_DICTS: "dict_of_dicts"
* URI: "uri"
* AUTH: "auth"
* LIST: "list"
* GCS: "gcs"
* S3: "s3"
* WASB: "wasb"
* DOCKERFILE: "dockerfile"
* GIT: "git"
* IMAGE: "image"
* EVENT: "event"
* ARTIFACTS: "artifacts"
* PATH: "path"
* METRIC: "metric"
* METADATA: "metadata"
* DATE: "date"
* DATETIME: "datetime" 

V1ArtifactsType

polyaxon.schemas.types.artifacts.V1ArtifactsType(files=None, dirs=None, workers=None)

Artifacts type allows to easily pass the files and directories to initialize as a single parameter.

If used as an input type, Polyaxon can resolve several connections (blob storage and volumes) and will turn this input type into an initializer with logic to download/provide the requested files and/or directories into a context for your jobs and operations.

  • Args:
    • files: Union[List[str], List[[str, str]], optional, list of file subpaths or a list of [path from, path to].
    • dirs: Union[List[str], List[[str, str]], optional, list of directory subpaths or a list of [path from, path to].

YAML usage

Usage in IO and params definition

The inputs definition

inputs:
  - name: some-file-names
    type: artifacts
  - name: tensorboard-log-dir
    type: artifacts
  - name: dataset1
    type: artifacts

The params usage

params:
  some-file-names: {value: {files: ["file1", "/path/to/file2"]}}
  custom-file-paths: {value: {files: [["file1", "to/this/path/file1"], "/path/to/file2"]}}
  tensorboard-log-dir: {value: {dirs: ["/tensorboard-logs"]}, connection: "foo", toInit: True}
  dataset1: {value: {value: {dirs: ["/"]}, connection: "s3-dataset", init: True}

The first param will be just a list of files definition that the user should know how to handle in their program.

The second param, Polyaxon will load only that directory path from connection "foo". This connection could be any a bucket or a volume.

In the third param, dataset1 will be resolved automatically because Polyaxon knows about that connection and that it's of type S3. It will load all data in that S3 bucket before starting the experiment.

Usage in initializers

version:  1.1
kind: component
run:
  kind: job
  init:
  - artifacts:
      files: ["file1", "/path/to/file2"]
  - artifacts:
      files: [["file1", "to/this/path/file1"], "/path/to/file2"]
  - artifacts:
      dirs: ["/tensorboard-logs"]
    connection: foo
  - artifacts:
      dirs: ["/"]
    connection: s3-datase

  container:
    ...

Python usage

Usage in IO and params definition

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="some-file-names",
        type=types.ARTIFACTS,
    ),
    V1IO(
        name="tensorboard-log-dir",
        type=types.ARTIFACTS,
    ),
    V1IO(
        name="dataset1",
        type=types.ARTIFACTS,
    )
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(value=types.V1ArtifactsType(files=["file1", "/path/to/file2"])),
    "test2": V1Param(
        value=types.V1ArtifactsType(dirs=["/tensorboard-logs"]),
        connection="foo",
        to_init=True
    ),
    "test3": V1Param(
        value=types.V1ArtifactsType(dirs=["/"]),
        connection="s3-dataset",
        to_init=True
    ),
}

Usage in initializers

from polyaxon.polyflow import V1Component, V1Init, V1Job
from polyaxon.schemas.types import V1ArtifactsType
from polyaxon.k8s import k8s_schemas
component = V1Component(
    run=V1Job(
       init=[
            V1Init(
                artifacts=V1ArtifactsType(files=["file1", "/path/to/file2"])
            ),
            V1Init(
                artifacts=V1ArtifactsType(dirs=["/tensorboard-logs"]),
                connection="foo"
            ),
            V1Init(
                artifacts=V1ArtifactsType(dirs=["/"]),
                connection="s3-dataset"
            ),
       ],
       container=k8s_schemas.V1Container(...)
    )
)

V1GitType

polyaxon.schemas.types.git.V1GitType(url=None, revision=None, flags=None)

Git type allows you to pass a git repo as a parameter.

If used as an input type, Polyaxon can resolve several git connections and will turn this input type into an initializer with logic to clone the repo with support for branches and commits, the requested repo will be exposed as a context for your jobs and operations.

  • Args:
    • url: str, optional.
    • revision: str, optional.
    • flags: List[str], optional

YAML usage

Usage in IO and params definition

The inputs definition

inputs:
  - name: test1
    type: git
  - name: test2
    type: git

The params usage

params:
  test1: {value: {"url": "https://github.com/tensorflow/models"}}
  test2: {value: {revision: "branchA"}, connection: "my-git-connection"}
  test3: {
    value: {flags: ["--recursive", "-c http.sslVerify=false"]},
    connection: "my-git-connection",
  }

Usage in initializers

version:  1.1
kind: component
run:
  kind: job
  init:
  - git: {"url": "https://github.com/tensorflow/models"}
  - git:
      revision: branchA
    connection: my-git-connection
  - git:
      flags: ["--recursive", "-c http.sslVerify=false"]
    connection: my-git-connection
  ...

Python usage

Usage in IO and params definition

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.GIT,
    ),
    V1IO(
        name="test2",
        type=types.GIT,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(
        value=types.V1GitType(url="https://github.com/tensorflow/models")
    ),
    "test2": V1Param(
        value=types.V1GitType(revision="branchA"),
        connection="my-git-connection",
    ),
}

Usage in initializers

from polyaxon.polyflow import V1Component, V1Init, V1Job
from polyaxon.schemas.types import V1GitType
from polyaxon.k8s import k8s_schemas
component = V1Component(
    run=V1Job(
       init=[
            V1Init(
              git=V1GitType(url="https://github.com/tensorflow/models"),
            ),
            V1Init(
              git=V1GitType(revision="branchA"),
              connection="my-git-connection",
            ),
       ],
       container=k8s_schemas.V1Container(...)
    )
)

V1GcsType

polyaxon.schemas.types.gcs.V1GcsType(bucket=None, blob=None)

GCS type.

  • Args:
    • bucket: str
    • blob: str

YAML usage

The inputs definition

inputs:
  - name: test1
    type: gcs
  - name: test2
    type: gcs

The params usage

params:
  test1: {value: {bucket: "gs://bucket1"}}
  test1: {value: {bucket: "gs://bucket2", blob: "blobName"}}

Python usage

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.GCS,
    ),
    V1IO(
        name="test2",
        type=types.GCS,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(value=types.V1GcsType(bucket="gs://bucket1")),
    "test2": V1Param(value=types.V1GcsType(bucket="gs://bucket1", blob="blobName")),
}

V1S3Type

polyaxon.schemas.types.s3.V1S3Type(bucket=None, key=None)

S3 type.

  • Args:
    • bucket: str
    • key: str

YAML usage

The inputs definition

inputs:
  - name: test1
    type: s3
  - name: test2
    type: s3

The params usage

params:
  test1: {value: {bucket: "s3://bucket1"}}
  test1: {value: {bucket: "s3://bucket2", key: "keyName"}}

Python usage

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.S3,
    ),
    V1IO(
        name="test2",
        type=types.S3,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(value=types.V1S3Type(bucket="s3://bucket1")),
    "test2": V1Param(value=types.V1S3Type(bucket="s3://bucket1", key="keyName")),
}

V1WasbType

polyaxon.schemas.types.wasb.V1WasbType(container=None, storage_account=None, path=None)

Wasb type.

  • Args:
    • container: str
    • storage_account: str
    • path: str

YAML usage

The inputs definition

inputs:
  - name: test1
    type: wasb
  - name: test2
    type: wasb

The params usage

params:
  test1: {value: {container: "containerName", user: "username"}}
  test2: {value: {container: "containerName", user: "username", path: "some/path"}}

Python usage

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.WASB,
    ),
    V1IO(
        name="test2",
        type=types.WASB,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(value=types.V1WasbType(container="containerName", user="username")),
    "test2": V1Param(
        value=types.V1WasbType(
             container="containerName2", user="username", path="path/value"
        )
     ),
}

V1FileType

polyaxon.schemas.types.file.V1FileType(content=None, filename=None, chmod=None, kind=None)

File type.

This type allows you to easily construct pass a file content without the need to clone repo or download a from an external localtion. It exposes a very simple interface for generating a file or a script that can be used by your containers.

  • Args:
    • content: str
    • filename: str, optional
    • kind: str, optional
    • chmod: str, optional

YAML usage

Usage in IO and params definition

The inputs definition

inputs:
  - name: test1
    type: file
  - name: test2
    type: file

The params usage

params:
  test1:
    value:
      filename: script.sh
      chmod: +x
      content: |
        #!/usr/bin/env bash

        echo 'This is a test.' | wc -w
  test2:
    value:
      filename: script.py
      content: |
        print("hello world")

Usage in initializers

 ```yaml
version:  1.1
kind: component
run:
  kind: job
  init:
  - file:
      filename: script.sh
      chmod: +x
      content: |
        #!/usr/bin/env bash

        echo 'This is a test.' | wc -w
  - file:
      filename: script.py
      content: |
        print("hello world")
    ...

Python usage

Usage in IO and params definition

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.FILE,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param

params = {
    "test1": V1Param(
        value=types.V1FileType(
            filename="script.sh",
            chmod="+x",
            content="#!/usr/bin/env bash
echo 'This is a test.' | wc -w",
        )
    ),
}

Usage in initializers

from polyaxon.polyflow import V1Component, V1Init, V1Job
from polyaxon.schemas.types import V1FileType
from polyaxon.k8s import k8s_schemas
component = V1Component(
    run=V1Job(
       init=[
            V1Init(
                file=V1FileType(
                    filename="script.sh",
                    chmod="+x",
                    content="#!/usr/bin/env bash
echo 'This is a test.' | wc -w",
                )
            ),
       ],
       container=k8s_schemas.V1Container(...)
    )
)

Fields

  • filename: an optional filename.
  • content: the content of the file or script.
  • chmod: Custom permission for the generated file.
  • kind: artifact kind, default to file.

V1DockerfileType

polyaxon.schemas.types.dockerfile.V1DockerfileType(image=None, env=None, path=None, copy=None, post_run_copy=None, run=None, lang_env=None, uid=None, gid=None, username=None, filename=None, workdir=None, workdir_path=None, shell=None)

Dockerfile type.

This type allows you to easily construct a dockerfile without the need to clone repo or download a file. It exposes a very simple interface for generating a dockerfile to build your container.

  • Args:
    • image: str
    • env: Dict, optional
    • path: List[str], optional
    • copy: Union[List[str], List[[str, str]], optional
    • post_run_copy: Union[List[str], List[[str, str]], optional
    • run: List[str], optional
    • lang_env: str, optional
    • uid: str, optional
    • gid: str, optional
    • username: str, optional, default 'polyaxon'
    • filename: str, optional
    • workdir: str, optional
    • workdir_path: str, optional
    • shell: str, optional

YAML usage

Usage in IO and params definition

The inputs definition

inputs:
  - name: test1
    type: dockerfile

The params usage

params:
  test1:
    value:
      image: test
      run: ["pip install package1"]
      env: {'KEY1': 'en_US.UTF-8', 'KEY2':2}

Usage in initializers

 ```yaml
version:  1.1
kind: component
run:
  kind: job
  init:
  - dockerfile:
      image: test
      run: ["pip install package1"]
      env: {'KEY1': 'en_US.UTF-8', 'KEY2':2}
    ...

Python usage

Usage in IO and params definition

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.DOCKERFILE,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(
        value=types.V1DockerfileType(
            image="test:version",
            run=["pip install package1"],
            env={'KEY1': 'en_US.UTF-8', 'KEY2':2}
        )
    ),
}

Usage in initializers

from polyaxon.polyflow import V1Component, V1Init, V1Job
from polyaxon.schemas.types import V1DockerfileType
from polyaxon.k8s import k8s_schemas
component = V1Component(
    run=V1Job(
       init=[
            V1Init(
                dockerfile=V1DockerfileType(
                    image="test",
                    run=["pip install package1"],
                    env={'KEY1': 'en_US.UTF-8', 'KEY2':2},
                )
            ),
       ],
       container=k8s_schemas.V1Container(...)
    )
)

Fields

  • image: the base image to use, is will exposed as FROM command in the dockerfile.
  • env: environment variables dictionary that will be exposed as ENV sections.
  • path: list of paths to be added to your PATH environment variable.
  • copy: a list a copy commands that will be exposed as list of COPY commands. You can pass a

Union[List[str], List[[str, str]], if a str is passed it will be placed under the workdir, if [str, str] is passed the path will be placed under the second string.

  • postRunCopy: Similar to the copy section,

the COPY commands will be placed after RUN commands. This could be very useful to leverage any cached commands before copying new artifacts.

  • run: a list a run commands that will be exposed as list of RUN commands.
  • langEnv: if passed it will expose these environment variable: ENV LC_ALL, LANG, LANGUAGE
  • uid and gid: will create a new user based on these 2 values.
  • username: an optional name to use for the uid/gid, default is 'polyaxon' user.
  • filename: an optional name for your dockerfile, default is Dockerfile.

N.B. this is not a path, if you need to generate the dockerfile on a custom path, you will need to set the path key on the init container definition.

  • workdir: the WORKDIR for your dockerfile, default is /code
  • workdirPath: the local workdir to copy to the docker container.
  • shell: shell type environment variable, default /bin/bash.

Example

image: image:tag
env:
  KEY1: value1
  KEY2: value2
path:
- module/add/to/path
copy:
- copy/local/requirements.txt
- [copy/.cache/dir, /destination]
run:
- pip install ...
- mv foo bar
postRunCopy:
- copy/local/path
- [copy/local/path, /path/to/user/in/container]
langEnv: en_US.UTF-8
uid: 2222
gid: 1111
filename: Dockerfile2
workdir: ../my-code

V1UriType

polyaxon.schemas.types.uri.V1UriType(user=None, password=None, host=None)

Uri type.

  • Args:
    • user: str
    • password: str
    • host: str

YAML usage

The inputs definition

inputs:
  - name: test1
    type: uri
  - name: test2
    type: uri

The params usage

params:
  test1: {value: "username1:[email protected]"}
  test1: {value: {"user": "username2", "password": "password2", "host": "service.com"}

Python usage

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.URI,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(
        value=types.V1AuthType(user="username1", password="password1", host="service.com")
    ),
}

Normally you should not be passing auth details in plain values.


V1AuthType

polyaxon.schemas.types.auth.V1AuthType(user=None, password=None)

Auth type.

  • Args:
    • user: str
    • password: str

YAML usage

The inputs definition

inputs:
  - name: test1
    type: auth
  - name: test2
    type: auth

The params usage

params:
  test1: {value: "username1:password1"}
  test1: {value: {"user": "username2", "password": "password2"}}

Python usage

The inputs definition

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1IO
inputs = [
    V1IO(
        name="test1",
        type=types.AUTH,
    ),
    V1IO(
        name="test2",
        type=types.AUTH,
    ),
]

The params usage

from polyaxon import types
from polyaxon.schemas import types
from polyaxon.polyflow import V1Param
params = {
    "test1": V1Param(value=types.V1AuthType(user="username1", password="password1")),
    "test2": V1Param(value=types.V1AuthType(user="username2", password="password2")),
}

Normally you should not be passing auth details in plain values.

This type validate several values:

String values:

  • '{"user": "foo", "password": "bar"}'
  • 'foo:bar'

Dict values:

  • {"user": "foo", "password": "bar"}