Name | splight-cli JSON |
Version |
5.6.1
JSON |
| download |
home_page | None |
Summary | Splight Command Line Interface |
upload_time | 2025-08-01 16:40:33 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <4.0.0,>=3.11 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Splight CLI
---
## Table of Content
- [Splight CLI](#splight-cli)
- [Table of Content](#table-of-content)
- [Introduction](#introduction)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Configuration](#configuration)
- [Create Developer Credentials](#create-developer-credentials)
- [Configure Splight CLI](#configure-splight-cli)
- [Commands](#commands)
- [Component](#component)
- [Configure](#configure)
- [Engine](#engine)
- [Workspace](#workspace)
- [Developing Components](#developing-components)
- [What is a component?](#what-is-a-component)
- [Creating a Component](#creating-a-component)
- [Component Core](#component-core)
- [Component Initialization](#component-initialization)
- [Component Configuration](#component-configuration)
- [Running Locally](#running-locally)
## Introduction
The Splight Command Line Interface is a unified tool to interact with _Splight
Platform_. It contains different features that a user can use for creating, deloping, and
publishing components.
## Getting Started
### Installation
_SplightCLI_ is a Python package that can be installed using `pip`
```bash
pip install splight-cli
```
Once you have installed `splight-cli` you can check the installation with
```bash
splight --version
```
You should see something like
```bash
$ splight
Usage: splight [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
...
```
You can enable auto completions by running
```bash
splight --install-completion <SHELL>
```
where SHELL is either bash, zsh, fish, powershell, pwsh.
This will add commands at the bottom of your shell's dotfile (zsh example):
```bash
autoload -Uz compinit
zstyle ':completion:*' menu select
fpath+=~/.zfunc
```
If these do not work after restarting the shell, you can try adding
```bash
compinit -D
```
to the bottom of your shell's dotfile, in order to recreate the autocompletions file, and restarting again.
### Configuration
Before using the _Splight CLI_, you need to configure it. In order to do it you need
to create your _User credentials_ from the platform and then you will be able to
configure _Splight CLI_.
#### Create Developer Credentials
Go to the [Splight Platform](https://app.splight-ae.com), and in your _User Configuration > Account_, in the right side pannel you will find the section _Developers_ and the subsection _Credentials_. Under the _Credentials_ subsection select “**New access key”.** This will generate a Client Access ID and Secret Key which are
the credentials you will use for configuring _Splight CLI_. These credentials should
not be share with other users.
Also, you need to keep in mind that the Secret Key is only shown once, if you loose the
Key you will need to create a new set of Access Credentials.
#### Configure Splight CLI
The fastest and easiest way for configuring _Splight CLI_ is running on your terminal
the following command
```bash
splight configure
```
After entering the above command will ask you for the credentials you have created before.
## Commands
This section introduce you to many of the common features and options provided by
_Splight CLI_.
The tool contains a set of commands that can be used for different purposes.
In the following subsections, we will go through each of the commands that can be
used.
The basic usage is
```bash
splight <command> [--help]
```
where `<command>` is the command you want to use, and optionally you can add the flag
`--help` to each one of the commands to get more information about the given command.
### Component
This is probably the most important command and the one you will use most. The command `component` allow you to operate over components, this mean you can create components, test locally components, push private or public components to _Splight Hub_, download
existing component in _Splight Hub_ and delete them.
In the following section we will cover in details the development process of a
component, here we will only cover the different sub-commands you can use
- Create a new component
To create a new component the command is
```bash
splight component create <name> -v <version> -p <path>
```
The parameters `<name>` and
`<version>` are the name and version of the component to be created,
while the `<path>` parameter is the path of the directory where the
component will be created.
The three commands parameters `<name>` and `<version>` are
commong between all the sub-commands.
If no `<path>` is specified, you will find some
files that defines the basic structure of the component source
code in the same directory where the command was executed. If `<path>`
is specified, then the files will be located in the specified path.
- Create component Readme
As a component developer, you can generate a README.md file automatically using the
command
```bash
splight component readme <path> [-f]
```
This way, based on the `spec.json` file the readme is generated and you don't need
to care about basic descriptions like input, output, custom types and more.
### Configure
This command is used for configuring Splight CLI and can be used as many times as you
want.
The command is
```bash
splight configure
```
And it will prompt you to enter some pieces of information that needed by Splight CLI.
This command is quite useful when is used along with `workspace` command.
You can also retrieve one of the parameters using the `get` command:
```bash
splight configure get <parameter>
```
for example for reading the `SPLIGHT_PLATFORM_API_HOST`:
```bash
splight configure get splight_platform_api_host
```
In the same way you can modify one parameter using the `set` command
```bash
splight configure set <parameter> <value>
```
#### Component
- List component
You can list all the components with the command
```bash
splight hub component list
```
- Pull or download a component
For downloading an existing component in _Splight Hub_ you can use
```bash
splight hub component pull <name> <version>
```
This will download the component source code to your machine.
- Push a component
For pushing a new component or component version to _Splight Hub_ the command is
```bash
splight hub component push <path>
```
Where `<path>` is the path (relative or absolute) for the source code of the
component to be uploded.
- List component versions
You can also list all the version of given component with
```bash
splight hub component versions <name>
```
### Engine
The `engine` command is used for interacting with the Splight Engine. So far, the available
subcommands provide an interface for creating, reaading and deleting resources in the engine.
The command is
```bash
splight engine <subcommand> <action> [extra args]
```
depending on the which sub-command you use you can get different actions
to perform
The valid sub-commands so far are:
- `asset`
- `attribute`
- `component`
- `datalake`
- `file`
- `graph`
- `query`
- `secret`
### Workspace
This command allows you to manage different workspaces in the same computer. This can
be useful for managing different environments of different users that share the same
computer.
The command is
```bash
splight workspace <sub-command>
```
The available subcommands are
- `create <name>` to create a new workspace. After the creation of a new worskpace you need to configure _Splight CLI_ with `splight configure`.
- `delete <name>` to delete an existing workspace.
- `list` to list all workspaces. Current workspace displays a '\*' to the left.
- `select <name>` to switch between different configured workspaces.
- `show <name>` to display the contents of an existing workspace.
## Developing Components
Now it's time to talk about the process for developing components.
### What is a component?
A component is a package of code that can be executed in the Splight platform. Splight
Hub is the space that manages all components that exist in Splight. You can upload your
own coded component for your usability or even allow other people in Splight to use it!
The expected flow for your component is the following:
- You create your component and code it locally
- Upload it to Splight Hub
- Use your component in Splight, where all your data is available
### Creating a Component
To create a component with the Splight Hub CLI, open a terminal and change the directory to the one where you want to work.
Execute the following command:
```bash
splight component create <name> <version>
```
This will create a directory with the following structure:
```
<name>-<version>
│ main.py
│ Initialization
│ spec.json
│ README.md
```
- `main.py` : The main file to contian the component's code.
- `Initialization` : Execute instructions for the component to be initialized.
- `spec.json` : JSON file where the component metadata is set.
- `README.md` : Text that describes the component and how it works
#### Component Core
When creating a component, inside `main.py` you will find a component template
already written in python for you, in order to make it easier to write the component code.
For example, when you create an algorithm component, in `main.py` will have the following:
```python
import random
from typing import Optional, Type
import typer
from splight_lib.component import SplightBaseComponent
from splight_lib.execution import Task
from splight_lib.logging import getLogger
from splight_lib.models import Number
app = typer.Typer(pretty_exceptions_enable=False)
class ExampleComponent(SplightBaseComponent):
def __init__(self, component_id: str):
super().__init__(component_id)
self._logger = getLogger("MyComponent")
def start(self):
self.execution_engine.start(
Task(
handler=self._run,
args=(self.input.min, self.input.max),
period=self.input.period,
)
)
def _run(self, min_value: float, max_value: float):
value = self._give_a_random_value(
self.input.lower_bound, self.input.upper_bound
)
preds = Number(
value=value,
)
preds.save()
self._logger.info(f"\nValue = {value}\n")
def _give_a_random_value(self, min: float, max: float) -> float:
return (max - min) * random.random() + min
@app.command()
def main(
component_id: str = typer.Option(...),
input: Optional[str] = typer.Option(None),
):
logger = getLogger("MyComponent")
component = ExampleComponent(component_id=component_id)
try:
component.start()
except Exception as exc:
logger.exception(exc, tags="EXCEPTION")
component.stop()
if __name__ == "__main__":
app()
```
The component class must always be called `Main` and must inherit from one of
`splight_lib` abstract component classes. Also, super() init must be called. The
execution of the component starts when the method `start()` is called, so the method
should be implemented by the developer that is writting the component. Also, we
provide you a lot of useful functions in our package so you can use them to interact
with the platform and make better components
Raw data
{
"_id": null,
"home_page": null,
"name": "splight-cli",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.11",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Splight Dev <dev@splight-ae.com>",
"download_url": "https://files.pythonhosted.org/packages/23/9b/9eb17c06f4239c2f8b7ca6bbfe5385bf4f6e67106a7f1d797d69c3b910cb/splight_cli-5.6.1.tar.gz",
"platform": null,
"description": "# Splight CLI\n\n---\n\n## Table of Content\n\n- [Splight CLI](#splight-cli)\n - [Table of Content](#table-of-content)\n - [Introduction](#introduction)\n - [Getting Started](#getting-started)\n - [Installation](#installation)\n - [Configuration](#configuration)\n - [Create Developer Credentials](#create-developer-credentials)\n - [Configure Splight CLI](#configure-splight-cli)\n - [Commands](#commands)\n - [Component](#component)\n - [Configure](#configure)\n - [Engine](#engine)\n - [Workspace](#workspace)\n - [Developing Components](#developing-components)\n - [What is a component?](#what-is-a-component)\n - [Creating a Component](#creating-a-component)\n - [Component Core](#component-core)\n - [Component Initialization](#component-initialization)\n - [Component Configuration](#component-configuration)\n - [Running Locally](#running-locally)\n\n## Introduction\n\nThe Splight Command Line Interface is a unified tool to interact with _Splight\nPlatform_. It contains different features that a user can use for creating, deloping, and\npublishing components.\n\n## Getting Started\n\n### Installation\n\n_SplightCLI_ is a Python package that can be installed using `pip`\n\n```bash\npip install splight-cli\n```\n\nOnce you have installed `splight-cli` you can check the installation with\n\n```bash\nsplight --version\n```\n\nYou should see something like\n\n```bash\n$ splight\n\nUsage: splight [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --help Show this message and exit.\n\nCommands:\n...\n```\n\nYou can enable auto completions by running\n\n```bash\nsplight --install-completion <SHELL>\n```\n\nwhere SHELL is either bash, zsh, fish, powershell, pwsh.\n\nThis will add commands at the bottom of your shell's dotfile (zsh example):\n\n```bash\nautoload -Uz compinit\nzstyle ':completion:*' menu select\nfpath+=~/.zfunc\n```\n\nIf these do not work after restarting the shell, you can try adding\n\n```bash\ncompinit -D\n```\n\nto the bottom of your shell's dotfile, in order to recreate the autocompletions file, and restarting again.\n\n### Configuration\n\nBefore using the _Splight CLI_, you need to configure it. In order to do it you need\nto create your _User credentials_ from the platform and then you will be able to\nconfigure _Splight CLI_.\n\n#### Create Developer Credentials\n\nGo to the [Splight Platform](https://app.splight-ae.com), and in your _User Configuration > Account_, in the right side pannel you will find the section _Developers_ and the subsection _Credentials_. Under the _Credentials_ subsection select \u201c**New access key\u201d.** This will generate a Client Access ID and Secret Key which are\nthe credentials you will use for configuring _Splight CLI_. These credentials should\nnot be share with other users.\n\nAlso, you need to keep in mind that the Secret Key is only shown once, if you loose the\nKey you will need to create a new set of Access Credentials.\n\n#### Configure Splight CLI\n\nThe fastest and easiest way for configuring _Splight CLI_ is running on your terminal\nthe following command\n\n```bash\nsplight configure\n```\n\nAfter entering the above command will ask you for the credentials you have created before.\n\n## Commands\n\nThis section introduce you to many of the common features and options provided by\n_Splight CLI_.\n\nThe tool contains a set of commands that can be used for different purposes.\nIn the following subsections, we will go through each of the commands that can be\nused.\n\nThe basic usage is\n\n```bash\nsplight <command> [--help]\n```\n\nwhere `<command>` is the command you want to use, and optionally you can add the flag\n`--help` to each one of the commands to get more information about the given command.\n\n### Component\n\nThis is probably the most important command and the one you will use most. The command `component` allow you to operate over components, this mean you can create components, test locally components, push private or public components to _Splight Hub_, download\nexisting component in _Splight Hub_ and delete them.\n\nIn the following section we will cover in details the development process of a\ncomponent, here we will only cover the different sub-commands you can use\n\n- Create a new component\n\n To create a new component the command is\n\n ```bash\n splight component create <name> -v <version> -p <path>\n ```\n\n The parameters `<name>` and\n `<version>` are the name and version of the component to be created,\n while the `<path>` parameter is the path of the directory where the\n component will be created.\n The three commands parameters `<name>` and `<version>` are\n commong between all the sub-commands.\n\n If no `<path>` is specified, you will find some\n files that defines the basic structure of the component source\n code in the same directory where the command was executed. If `<path>`\n is specified, then the files will be located in the specified path.\n\n- Create component Readme\n\n As a component developer, you can generate a README.md file automatically using the\n command\n\n ```bash\n splight component readme <path> [-f]\n ```\n\n This way, based on the `spec.json` file the readme is generated and you don't need\n to care about basic descriptions like input, output, custom types and more.\n\n### Configure\n\nThis command is used for configuring Splight CLI and can be used as many times as you\nwant.\n\nThe command is\n\n```bash\nsplight configure\n```\n\nAnd it will prompt you to enter some pieces of information that needed by Splight CLI.\nThis command is quite useful when is used along with `workspace` command.\n\nYou can also retrieve one of the parameters using the `get` command:\n\n```bash\nsplight configure get <parameter>\n```\n\nfor example for reading the `SPLIGHT_PLATFORM_API_HOST`:\n\n```bash\nsplight configure get splight_platform_api_host\n```\n\nIn the same way you can modify one parameter using the `set` command\n\n```bash\nsplight configure set <parameter> <value>\n```\n\n#### Component\n\n- List component\n\n You can list all the components with the command\n\n ```bash\n splight hub component list\n ```\n\n- Pull or download a component\n\n For downloading an existing component in _Splight Hub_ you can use\n\n ```bash\n splight hub component pull <name> <version>\n ```\n\n This will download the component source code to your machine.\n\n- Push a component\n\n For pushing a new component or component version to _Splight Hub_ the command is\n\n ```bash\n splight hub component push <path>\n ```\n\n Where `<path>` is the path (relative or absolute) for the source code of the\n component to be uploded.\n\n- List component versions\n\n You can also list all the version of given component with\n\n ```bash\n splight hub component versions <name>\n ```\n\n### Engine\n\nThe `engine` command is used for interacting with the Splight Engine. So far, the available\nsubcommands provide an interface for creating, reaading and deleting resources in the engine.\n\nThe command is\n\n```bash\nsplight engine <subcommand> <action> [extra args]\n```\n\ndepending on the which sub-command you use you can get different actions\nto perform\n\nThe valid sub-commands so far are:\n\n- `asset`\n- `attribute`\n- `component`\n- `datalake`\n- `file`\n- `graph`\n- `query`\n- `secret`\n\n### Workspace\n\nThis command allows you to manage different workspaces in the same computer. This can\nbe useful for managing different environments of different users that share the same\ncomputer.\n\nThe command is\n\n```bash\nsplight workspace <sub-command>\n```\n\nThe available subcommands are\n\n- `create <name>` to create a new workspace. After the creation of a new worskpace you need to configure _Splight CLI_ with `splight configure`.\n- `delete <name>` to delete an existing workspace.\n- `list` to list all workspaces. Current workspace displays a '\\*' to the left.\n- `select <name>` to switch between different configured workspaces.\n- `show <name>` to display the contents of an existing workspace.\n\n## Developing Components\n\nNow it's time to talk about the process for developing components.\n\n### What is a component?\n\nA component is a package of code that can be executed in the Splight platform. Splight\nHub is the space that manages all components that exist in Splight. You can upload your\nown coded component for your usability or even allow other people in Splight to use it!\n\nThe expected flow for your component is the following:\n\n- You create your component and code it locally\n- Upload it to Splight Hub\n- Use your component in Splight, where all your data is available\n\n### Creating a Component\n\nTo create a component with the Splight Hub CLI, open a terminal and change the directory to the one where you want to work.\n\nExecute the following command:\n\n```bash\nsplight component create <name> <version>\n```\n\nThis will create a directory with the following structure:\n\n```\n<name>-<version>\n\u2502 main.py\n\u2502 Initialization\n\u2502 spec.json\n\u2502 README.md\n```\n\n- `main.py` : The main file to contian the component's code.\n- `Initialization` : Execute instructions for the component to be initialized.\n- `spec.json` : JSON file where the component metadata is set.\n- `README.md` : Text that describes the component and how it works\n\n#### Component Core\n\nWhen creating a component, inside `main.py` you will find a component template \nalready written in python for you, in order to make it easier to write the component code.\n\nFor example, when you create an algorithm component, in `main.py` will have the following:\n\n```python\nimport random\nfrom typing import Optional, Type\n\nimport typer\nfrom splight_lib.component import SplightBaseComponent\nfrom splight_lib.execution import Task\nfrom splight_lib.logging import getLogger\nfrom splight_lib.models import Number\n\napp = typer.Typer(pretty_exceptions_enable=False)\n\n\nclass ExampleComponent(SplightBaseComponent):\n def __init__(self, component_id: str):\n super().__init__(component_id)\n self._logger = getLogger(\"MyComponent\")\n\n def start(self):\n self.execution_engine.start(\n Task(\n handler=self._run,\n args=(self.input.min, self.input.max),\n period=self.input.period,\n )\n )\n\n def _run(self, min_value: float, max_value: float):\n value = self._give_a_random_value(\n self.input.lower_bound, self.input.upper_bound\n )\n preds = Number(\n value=value,\n )\n preds.save()\n self._logger.info(f\"\\nValue = {value}\\n\")\n\n def _give_a_random_value(self, min: float, max: float) -> float:\n return (max - min) * random.random() + min\n\n\n@app.command()\ndef main(\n component_id: str = typer.Option(...),\n input: Optional[str] = typer.Option(None),\n):\n logger = getLogger(\"MyComponent\")\n component = ExampleComponent(component_id=component_id)\n try:\n component.start()\n except Exception as exc:\n logger.exception(exc, tags=\"EXCEPTION\")\n component.stop()\n\n\nif __name__ == \"__main__\":\n app()\n```\n\nThe component class must always be called `Main` and must inherit from one of\n`splight_lib` abstract component classes. Also, super() init must be called. The\nexecution of the component starts when the method `start()` is called, so the method\nshould be implemented by the developer that is writting the component. Also, we\nprovide you a lot of useful functions in our package so you can use them to interact\nwith the platform and make better components\n",
"bugtrack_url": null,
"license": null,
"summary": "Splight Command Line Interface",
"version": "5.6.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "354b8d9eb8cedf9bd4f86db63ee27d1fffc1d34ca3fce1679653b46a925a72c5",
"md5": "395c8bf7fe2c8a3a12d953f632cbb39f",
"sha256": "35ce8864e3719e2b70de51fdafca3d878e7af4678f50e2e1c1dd7c1b1397f498"
},
"downloads": -1,
"filename": "splight_cli-5.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "395c8bf7fe2c8a3a12d953f632cbb39f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.11",
"size": 39533,
"upload_time": "2025-08-01T16:40:32",
"upload_time_iso_8601": "2025-08-01T16:40:32.310193Z",
"url": "https://files.pythonhosted.org/packages/35/4b/8d9eb8cedf9bd4f86db63ee27d1fffc1d34ca3fce1679653b46a925a72c5/splight_cli-5.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "239b9eb17c06f4239c2f8b7ca6bbfe5385bf4f6e67106a7f1d797d69c3b910cb",
"md5": "66b7d0ef7c8d0fb0cc86b906741bffb6",
"sha256": "6a1f5909b9d4926a7a2339d2549b6a56135518758b7ae50fbba899cb26b624e9"
},
"downloads": -1,
"filename": "splight_cli-5.6.1.tar.gz",
"has_sig": false,
"md5_digest": "66b7d0ef7c8d0fb0cc86b906741bffb6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.11",
"size": 109020,
"upload_time": "2025-08-01T16:40:33",
"upload_time_iso_8601": "2025-08-01T16:40:33.877633Z",
"url": "https://files.pythonhosted.org/packages/23/9b/9eb17c06f4239c2f8b7ca6bbfe5385bf4f6e67106a7f1d797d69c3b910cb/splight_cli-5.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-01 16:40:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "splight-cli"
}