Class - mitto.iov2.input.ExampleInput

JSON Schema

ExampleInput

Source of example data.

ExampleInput can be specified as an inputter in a job configuration via the use parameter:

use: mitto.iov2.input#ExampleInput

When used without any additional parameters, ExampleInput creates and returns 10,000 records of example data which can be passed to subsequent steps in a Mitto job. Each row contains the following columns / types:

Column

Python Type

id

int

data_string

str

data_datetime

datetime.datetime

data_date

datetime.date

data_float

float

data_bool

bool

Return 10,000 rows of data

{
   "input": {
        "use": "mitto.iov2.input#ExampleInput"
    },
    ...
}

Return 10,000 rows of data as Records, automatically adding id, last_modified, and value columns, with value containing the data.

{
   "input": {
        "use": "mitto.iov2.input#ExampleInput"
        "use_record": true
    },
    ...
}

Return 2 rows of data, as provided:

{
   "input": {
        "use": "mitto.iov2.input#ExampleInput"
        "data": [
             {
                "value": "($1,676,902.67)"
             }
             {
                "value": "$1,676,902.67"
             }
        ]
    },
    ...
}

Return 1 row of data, as provided, as Records:

{
   "input": {
        "use": "mitto.iov2.input#ExampleInput"
        "use_record": true
        "data": [
             {
                "value": "($1,676,902.67)"
                "last_modified": "2021-01-12"
             }
        ]
    }
    ...
}

TODO: I believe this section is a duplicate of the ExampleInput page and should be deleted here.

Python code can also be used to generate example data via python_code. The Python code that is provided must do two things:

  1. Define a function suitable for use as a method of the ExampleInput class. The function must accept a single argument, whose value will be self when called.

  2. Contain a statement assigning the function to ``self.inputter`.

Example code meeting the above requirements:

def inputter(self):
    cols = "abcdefghijk"
    for i in range(0, 10):
        yield {col: i for col in cols}
self.inputter = inputter

Example: using Python from a file in /var/mitto/data:

input: {
    use: mitto.iov2.input#ExampleInput
    python_code: example_data.py
}

Example: using Python embedded in the input section of the job config:

input: {
    use: mitto.iov2.input#ExampleInput
    python_code: [
        def inputter(self):
        .   cols = "abcdefghijk"
        .   for i in range(0, 10):
        .       yield {col: i for col in cols}
        self.inputter = inputter
    ]
}

type

object

properties

  • limit

Limit

The number of rows of example data to create and return.

Only used if data is not provided.

type

integer

default

10000

  • offset

Offset

Increment used when creating example data.

Only used if data is not provided.

type

integer

default

0

  • use_record

Use Record

Return example data as a Record, if true.

Record includes an id, last_modified, and value columns. value will contain the data. If data is present and a row contains a value for last_modified, that value is returned; otherwise, an increasing value is created and returned.

type

boolean

default

False

  • data

Data

Example data to return.

If present, a list of dict objects, each containing column names and values. Each dict contains one row of data that will be returned. Otherwise, data is automatically created and returned using limit and offset.

type

array

default

items

type

object

  • python_code

Python Code

Python code that creates example data.

The value can be:

  1. a list of strings containing Python code,

  2. the name of a file containing Python code located in {DATA_PATH}

  3. the fully qualified path to a file containing Python code

anyOf

type

string

type

array

items

type

string

additionalProperties

False