Splight Docs
  • Welcome
  • Getting Started
    • Get Your Keys
    • API Introduction
  • Resources
    • Alert
    • Asset
    • Component
    • Compute Node
    • Dashboard
    • File
    • Function
  • Settings
    • Account
    • Organization
    • Users
    • Authorization
    • Preferences
  • Guides
    • Invite User
    • First Asset
    • Lib Examples
Powered by GitBook
On this page
  • Creating a Component
  • Reading Components
  • Updating a Component
  • Deleting a Component
  • Routines
  • Creating a Routine
  • Reading Routines
  • Updating a Routine
  • Deleting a Routine

Was this helpful?

  1. Resources

Component

PreviousAssetNextCompute Node

Last updated 15 days ago

Was this helpful?

Components are the core building blocks of the Splight engine, as they are responsible for handling all data processing within the system. They come in two main forms: algorithms, which transform and analyze data, and connectors, which pass data between components. Despite their different roles, both types share the same structure and are defined in the same way. Each component includes a set of routines that are executed during runtime, enabling seamless interaction with the underlying infrastructure by sending and receiving data as needed.

There are many types of components available in Splight. If you're unsure which type best fits your needs, feel free to contact any member of the Splight team for guidance and support.


Creating a Component

To create a component, you need to specify the following parameters:

Parameter
Description
Required

component_name

The name of the component.

Yes

component_description

A description of the component.

No

component_version

The version of the component.

Yes

component_input

The inputs of the component.

Yes

component_output

The outputs of the component.

Yes

component_routine

The routines of the component.

Yes

deployment_capacity

The capacity of the component (small, medium, large).

Yes

custom_types

Custom types for the component.

No

endpoints

Endpoints of the component.

No

deployment_type

The type of deployment.

Yes

tags

Tags for the component.

No

We recomend creating the routines after creating the component. You can find more information in the section.

curl --request POST \
    --url https://api.splight.com/v3/engine/component/algorithms/
    --header 'authorization: Splight <access_id> <secret_key>' \
    --header 'content-type: application/json' \
    --data '{
        "name": "<component_name>",
        "description": "<component_description>", 
        "version": "<component_version>",
        "deployment_capacity": "<deployment_capacity>",
        "custom_types": [],
        "input": [
            "<component_input>"
        ],
        "output": [
            "<component_output>"
        ],
        "routines": [
            "<component_routine>"
        ],
        "endpoints": [],
        "deployment_type": "SPLIGHT_HOSTED",
        "tags": []
    }'
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key

url = "https://api.splight.com/v3/engine/component/algorithms/"

payload = {
    "name": "<component_name>",
    "description": "<component_description>", 
    "version": "<component_version>",
    "deployment_capacity": "<deployment_capacity>",
    "custom_types": [],
    "input": [
        "<component_input>"
    ],
    "output": [
        "<component_output>"
    ],
    "routines": [
        "<component_routine>"
    ],
    "endpoints": [],
    "deployment_type": "SPLIGHT_HOSTED",
    "tags": []
}
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
print(response.status_code)  # 201 indicates successful creation

Where the input and output fields dependends on the component type.


Reading Components

The Splight API provides a comprehensive set of endpoints for reading component data. You can retrieve information about all components or filter them based on specific criteria. The API supports various query parameters to help you narrow down your search.

Let's explore some examples of how to read components using the API. Below are simple code snippets using curl and Python:

Getting all Components

curl --request GET \
    --url https://api.splight.com/v3/engine/component/<component_type> \
    --header 'authorization: Splight <access_id> <secret_key>' \
import requests
ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
COMPONENT_TYPE = "<component_type>"  # Replace with your component type in plural

url = f"https://api.splight.com/v3/engine/component/{COMPONENT_TYPE}"
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
}
response = requests.get(url, headers=headers)

print(response.json())
print(response.status_code)  # 200 indicates successful retrieval

Where component_type is the type of the component (e.g., "algorithm", "connector"). If you want to retrieve all components, you can omit this parameter.

Retrive a single Component

curl --request GET \
    --url https://api.splight.com/v3/engine/component/<component_type>/<component_id> \
    --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
COMPONENT_TYPE = "<component_type>"  # Replace with your component type in plural
COMPONENT_ID = "<component_id>"  # Replace with your component ID

url = f"https://api.splight.com/v3/engine/component/{COMPONENT_TYPE}/{COMPONENT_ID}"
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
}
response = requests.get(url, headers=headers)

print(response.json())
print(response.status_code)  # 200 indicates successful retrieval

Updating a Component

Before updating a component, ensure that it is stopped, then perform the update and restart it afterward.

curl --request PATCH \
    --url https://api.splight.com/v3/engine/component/<component_type>/<component_id> \
    --header 'authorization : Splight <access_id> <secret_key>' \
    --header 'content-type: application/json' \
    --data '{
        "name": "<component_name>",
        "description": "<component_description>", 
        "version": "<component_version>",
        "deployment_capacity": "<deployment_capacity>",
        "custom_types": [],
        "input": [
            "<component_input>"
        ],
        "output": [
            "<component_output>"
        ],
        "routines": [
            "<component_routine>"
        ],
        "endpoints": [],
        "deployment_type": "SPLIGHT_HOSTED",
        "tags": []
    }'
import requests
ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
COMPONENT_TYPE = "<component_type>"  # Replace with your component type in plural
COMPONENT_ID = "<component_id>"  # Replace with your component ID

url = f"https://api.splight.com/v3/engine/component/{COMPONENT_TYPE}/{COMPONENT_ID}"
payload = {
    "name": "<component_name>",
    "description": "<component_description>",
    "version": "<component_version>",
    "deployment_capacity": "<deployment_capacity>",
    "custom_types": [],
    "input": [
        "<component_input>"
    ],
    "output": [
        "<component_output>"
    ],
    "routines": [
        "<component_routine>"
    ],
    "endpoints": [],
    "deployment_type": "SPLIGHT_HOSTED",
    "tags": []
}
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
    "Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.json())
print(response.status_code)  # 200 indicates successful update

All fields are the same as in the creation process and all of them can be updated, except for the component_id, which is required to identify the component being updated and cannot be changed.


Deleting a Component

curl --request DELETE \
    --url https://api.splight.com/v3/engine/component/<component_type>/<component_id> \
    --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
COMPONENT_TYPE = "<component_type>"  # Replace with your component type in plural
COMPONENT_ID = "<component_id>"  # Replace with your component ID

url = f"https://api.splight.com/v3/engine/component/COMPONENT_TYPE/{COMPONENT_ID}"
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
}
response = requests.delete(url, headers=headers)

print(response.status_code)  # 204 indicates successful deletion

Routines

Routines are the core of the component, as they are responsible for processing data.


Creating a Routine

The routines are defined in the component and can be created with the following parameters:

Parameter
Description
Required

routine_name

The name of the routine.

Yes

routine_description

A description of the routine.

No

component_id

The ID of the component to which the routine belongs.

Yes

routine_type

The type of the routine (e.g., "inference", "training").

Yes

routine_config

The configuration of the routine.

Yes

routine_input

The inputs of the routine.

Yes

routine_output

The outputs of the routine.

Yes

Each routine has a specific purpose and can be created using the following structure:

curl --request POST \
    --url https://api.splight.com/v3/engine/component/routines/ \
    --header 'authorization: Splight <access_id> <secret_key>' \
    --header 'content-type: application/json' \
    --data '{
        "name": "<routine_name>",
        "description": "<routine_description>", 
        "component_id": "<component_id>",
        "type": "<routine_type>,
        "config": [
            "<routine_config>"
        ],
        "input": [
            "<routine_input>"
        ],
        "output": [
            "<routine_output>"
        ]
    }'
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
COMPONENT_ID = "<component_id>"  # Replace with your component ID

url = "https://api.splight.com/v3/engine/component/routines/"
payload = {
    "name": "<routine_name>",
    "description": "<routine_description>", 
    "component_id": COMPONENT_ID,
    "type": "<routine_type>",
    "config": [
        "<routine_config>"
    ],
    "input": [
        "<routine_input>"
    ],
    "output": [
        "<routine_output>"
    ]
}
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
    "Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
print(response.status_code)  # 201 indicates successful creation

The routine types available dependes on the component type. Ask the Splight team for more information.


Reading Routines

As the component, the routines can be read in two ways: by retrieving all routines or by retrieving a single routine using its ID.

Getting All Routines

curl --request GET \
    --url https://api.splight.com/v3/engine/component/routines/?component_id=<component_id> \
    --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
COMPONENT_ID = "<component_id>"  # Replace with your component ID

url = f"https://api.splight.com/v3/engine/component/routines/?component_id={COMPONENT_ID}"
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
}
response = requests.get(url, headers=headers)
print(response.json())
print(response.status_code)  # 200 indicates successful retrieval

Updating a Routine

curl --request PATCH \
    --url https://api.splight.com/v3/engine/component/routines/<routine_id> \
    --header 'authorization: Splight <access_id> <secret_key>' \
    --header 'content-type: application/json' \
    --data '{
        "name": "<routine_name>",
        "description": "<routine_description>",
        "component_id": "<component_id>",
        "type": "<routine_type>",
        "config": [
            "<routine_config>"
        ],
        "input": [
            "<routine_input>"
        ],
        "output": [
            "<routine_output>"
        ]
    }'
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
ROUTINE_ID = "<routine_id>"  # Replace with your routine ID
COMPONENT_ID = "<component_id>"  # Replace with your component ID

url = f"https://api.splight.com/v3/engine/component/routines/{ROUTINE_ID}"
payload = {
    "name": "<routine_name>",
    "description": "<routine_description>", 
    "component_id": COMPONENT_ID,
    "type": "<routine_type>",
    "config": [
        "<routine_config>"
    ],
    "input": [
        "<routine_input>"
    ],
    "output": [
        "<routine_output>"
    ]
}
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
    "Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.json())
print(response.status_code)  # 200 indicates successful update

All fields are the same as in the creation process and all of them can be updated, except for the routine_id, which is required to identify the routine being updated and cannot be changed.


Deleting a Routine

curl --request DELETE \
    --url https://api.splight.com/v3/engine/component/routines/<routine_id> \
    --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
ROUTINE_ID = "<routine_id>"  # Replace with your routine ID

url = f"https://api.splight.com/v3/engine/component/routines/{ROUTINE_ID}"
headers = {
    "authorization": f"Splight {ACCESS_ID} {SECRET_KEY}",
}
response = requests.delete(url, headers=headers)

print(response.status_code)  # 204 indicates successful deletion
Creating a Routine