sdk.algorithm_version.create()

elements.sdk.api.algorithm_version

Create an Algorithm Version.

Given a top level Algorithm, create a new version, which must be semantically greater than the previously created version. Once an Algorithm Version has been created, it is immutable. Any changes require a new version to be created. Any semantically correct version supplied as part of the Algorithm Manifest will be considered value and assigned to this Algorithm Version. New versions will be required to be semantically greater than this version.

Parameters

  • algorithm_id (str) - Algorithm ID for which to create a version for
  • algorithm_manifest (AlgorithmManifest) - the JSON-like object that contains the details of the Algorithm (the filepath to execute, Data Source specifications, parameters, etc.). See more info on Algorithm Manifests here
👍

Algorithm Builder

See the Algorithm Builder section for more details on how to construct an Algorithm Version.

Returns

AlgorithmVersion

Example(s)

from elements.sdk.builders.algorithm_builder import AlgorithmManifest, DataType,
	InterfaceType

# Initialize algorithm manifest
manifest = AlgorithmManifest()

# Add required metadata to the manifest
manifest.metadata_required(
  manifest_version="0.1.0",
  description="Collect unique device counts in input data set",
  version=version
)

# Add descriptive tags to the manifest
manifest.metadata_tags(["device_traffic", "vehicle_traffic", "traffic", "device_count", "geolocation"])

# Specify the data type the algorithm manifest uses (required)
manifest.inputs_add_data_type(DataType.PINGS.value)

# Specify the output data types
manifest.outputs_add_data_types(output_data_types=["unique_device_count"],
                                observation_value_columns=["unique_device_count"])

# Specify the docker requirements and shell command to execute the algorithm script (if InterfaceType==FILESYSTEM_TASK_WORKER)
manifest.container_parameters_required(
  image="orbitalinsight/raw_foottraffic:ff1cf7c9",
  command=["python", "/orbital/base/algorithms/raw_foottraffic/src/py/raw_foottraffic/simple_foottraffic.py"])
manifest.container_parameters_resource_request(gpu=0, memory_gb=5, cpu_millicore=200)
manifest.interface_required(interface_type=InterfaceType.FILESYSTEM_TASK_WORKER.value)

# Set result grouping frequency
manifest.grouping_frequency("DAILY", 1)

# Add configurable parameters
manifest.parameter_add(name="min_dwell_time", type="integer", units="minutes", min=0, max=1440, default=0,
                       description="Minimum dwell time in minutes required for a ping to be included in unique device count. Default is 0 (i.e. all pings are included).")
manifest.parameter_add(name="max_dwell_time", type="integer", units="minutes", min=0, max=1440, default=1440,
                       description="Maximum dwell time in minutes required for a ping to be included in unique device count. Default is None (i.e. all pings are included).")

# Create algorithm version
my_algo_version = await sdk.algorithm_version.create(algorithm_id=algorithm_id, algorithm_manifest=manifest)

# Output (AlgorithmVersion)
{
    "algorithmVersion": {
        "algorithm": {
            "author": "papi_author-vulcan-oi",
            "displayName": "Traffic",
            "id": "2a66af26-8639-4caa-8875-f34d2486ede2",
            "name": "traffic"
        },
        "createdOn": "2022-10-27T18:58:54.756553Z",
        "id": "877516ff-66c6-46ea-86c7-97b786893035",
        "manifest": {
            "container_parameters": {
                "command": [
                    "python",
                    "/orbital/base/algorithms/raw_foottraffic/src/py/raw_foottraffic/simple_foottraffic.py"
                ],
                "image": "orbitalinsight/raw_foottraffic:ff1cf7c9",
                "resource_request": {
                    "cpu_millicore": 200.0,
                    "gpu": 0.0,
                    "memory_gb": 5.0
                }
            },
            "inputs": [
                {
                    "data_type_name": "pings",
                    "max_count": 1.0,
                    "min_count": 1.0
                }
            ],
            "interface": {
                "interface_type": "FILESYSTEM_TASK_WORKER"
            },
            "manifest_version": "0.1.0",
            "metadata": {
                "description": "Determine the unique device count per observation grouping",
                "tags": [
                    "foot_traffic",
                    "unique_device_count"
                ],
                "version": "0.0.8"
            },
            "outputs": {
                "observation_value_columns": [
                    "unique_device_count"
                ],
                "output_data_types": [
                    "unique_device_count"
                ]
            },
            "parameters": [
                {
                    "default": 0.0,
                    "description": "Minimum dwell time in minutes required for a ping to be included in unique device count. Default is 0 (i.e. all pings are included).",
                    "min": 0.0,
                    "name": "min_dwell_time",
                    "type": "integer",
                    "units": "minutes"
                },
                {
                    "default": 1440.0,
                    "description": "Maximum dwell time in minutes required for a ping to be included in unique device count. Default is None (i.e. all pings are included).",
                    "min": 1.0,
                    "name": "max_dwell_time",
                    "type": "integer",
                    "units": "minutes"
                }
            ]
        },
        "version": "0.0.8"
    }
}