# Hyperstack Python Client
![Tests](https://img.shields.io/github/actions/workflow/status/balancedscorpion/hyperstack/tests.yml?label=tests)
![Coverage](https://img.shields.io/codecov/c/github/balancedscorpion/hyperstack)
![PyPI](https://img.shields.io/pypi/v/hyperstack)
![Python Versions](https://img.shields.io/pypi/pyversions/hyperstack)
![License](https://img.shields.io/github/License/balancedscorpion/hyperstack)
![PyPI Downloads](https://img.shields.io/pypi/dm/hyperstack)
This is a Python client for interacting with the Hyperstack API
### Installation
```bash
pip install hyperstack
```
### Usage
First ensure you have your API key set in an environment variable.
To create an API key, visit you can review [Hyperstack's documentation](https://infrahub-doc.nexgencloud.com/docs/api-reference/getting-started-api/authentication/#api-keys).
Then add your API key to the environment variables.
```bash
export HYPERSTACK_API_KEY=<your API Key>
```
```python
import hyperstack
```
#### Create an environment if you don't have one
```python
hyperstack.create_environment('your-environment-name')
```
#### Set your environment
```python
hyperstack.set_environment('your-environment-name')
```
#### Create a VM
```python
hyperstack.create_vm(
name='first-vm',
image_name="Ubuntu Server 22.04 LTS R535 CUDA 12.2",
flavor_name='n2-RTX-A5000x1',
key_name="your-key",
user_data="",
create_bootable_volume=False,
assign_floating_ip=False,
count=1)
```
### One-click Deployments
Before you make any deployments, ensure you have set up your environment and [ssh-key](https://infrahub-doc.nexgencloud.com/docs/network/ssh/#create-an-ssh-key) as per the Hyperstack Documentation. Please note that the one-click deployments can take 5-10 minutes to be ready after the script has completed. The script completes when the machine is ready, but the machine still needs to download the docker image with ollama or python with notebooks within it. Further details can be found below within [One-click deployment further details](#one-click-deployment-further-details) section.
#### Deploy Ollama Server
First set-up your ssh key and environment. Then navigate to the hyperstack library and run:
```bash
hyperstack ollama --name ollama-server --flavor_name n2-RTX-A5000x1 --key_name your-key --environment your-environment
```
#### Deploy Pytorch server
The same command as above, but change ollama to pytorch
```bash
hyperstack pytorch --name ollama-server --flavor_name n2-RTX-A5000x1 --key_name your-key --environment your-environment
```
#### Deploy from Python
```python3
from hyperstack.deploy import deploy
deploy(deployment_type="pytorch", name="pytorch-vm", environment="your-environment", flavor_name="n2-RTX-A5000x1", key_name="your-key")
```
```python3
from hyperstack.deploy import deploy
deploy(deployment_type="ollama", name="ollama-vm", environment="your-environment", flavor_name="n2-RTX-A5000x1", key_name="your-key")
```
### One-click deployment further details
Here's a sample command to run the deployment.
```bash
hyperstack pytorch --name ollama-server --flavor_name n2-RTX-A5000x1 --key_name your-key --environment your-environment
```
After you run a command (for example the Pytorch server), you will receive the requested configuration and useful details will print out.
```bash
Environment set to: your-environment
Booting 12345
Attempt 1/4: VM 12345 status is BUILD. Waiting for 30 seconds.
Machine 12345 Ready
Public IP: xxx.xxx.xxx.xxx
In container credentials:
username: dockeruser
Password: xxxxxxxx
````
This includes your virtual machine id, public ip for to ssh into the machine, and your dockeruser credentials. This will default to a uuid, unless explicitly provided.
The machine is ready and will now download docker, the docker image with pytorch, juptyer notebooks inside and the configuration. This will take another 5-10 minutes, but for now, you will be able to ssh into the machine:
```bash
ssh -i ~/.ssh/ed25519 ubuntu@xxx.xxx.xxx.xxx
```
If you'd like to follow the installation:
Once ssh in the machine, you can try to open the docker container. Please note: it can sometimes take 5-10 minutes for docker to install and the docker image to be downloaded after the machine is ready. Please be patient with this. If you'd like to debug this you can do the following once ssh into the machine.
Apply the docker group to your current shell session:
```bash
newgrp docker
```
Check that docker and the image has indeed downloaded. This may take 5-10 minutes.
```bash
docker ps -a
```
Once it has downloaded you should see output like the below:
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
xxxxxxxxxxxx balancedscorpion/python3-pytorch-ubuntu "/entrypoint.sh /bin…" 2 minutes ago Up 2 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp pytorch
```
Now you can access the docker container. You can access this. For example, using VScode you can download ssh-connect and dev-containers to access this directly.
Raw data
{
"_id": null,
"home_page": "https://github.com/balancedscorpion/hyperstack",
"name": "hyperstack",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "api, wrapper, hyperstack, GPU",
"author": "Jamie Martin",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0f/0a/3ab98e62acf5537f72bb5c2370833c4e24a575d411a8fd3aac5774049300/hyperstack-0.2.6.tar.gz",
"platform": null,
"description": "# Hyperstack Python Client\n![Tests](https://img.shields.io/github/actions/workflow/status/balancedscorpion/hyperstack/tests.yml?label=tests)\n![Coverage](https://img.shields.io/codecov/c/github/balancedscorpion/hyperstack)\n![PyPI](https://img.shields.io/pypi/v/hyperstack)\n![Python Versions](https://img.shields.io/pypi/pyversions/hyperstack)\n![License](https://img.shields.io/github/License/balancedscorpion/hyperstack)\n![PyPI Downloads](https://img.shields.io/pypi/dm/hyperstack)\n\nThis is a Python client for interacting with the Hyperstack API\n\n### Installation\n\n```bash\npip install hyperstack\n```\n\n### Usage\n\nFirst ensure you have your API key set in an environment variable.\n\nTo create an API key, visit you can review [Hyperstack's documentation](https://infrahub-doc.nexgencloud.com/docs/api-reference/getting-started-api/authentication/#api-keys).\n\nThen add your API key to the environment variables.\n\n```bash\nexport HYPERSTACK_API_KEY=<your API Key>\n```\n\n```python\nimport hyperstack\n```\n\n#### Create an environment if you don't have one\n\n```python\nhyperstack.create_environment('your-environment-name')\n```\n\n#### Set your environment\n\n```python\nhyperstack.set_environment('your-environment-name')\n```\n\n#### Create a VM\n```python\nhyperstack.create_vm(\n name='first-vm',\n image_name=\"Ubuntu Server 22.04 LTS R535 CUDA 12.2\",\n flavor_name='n2-RTX-A5000x1',\n key_name=\"your-key\",\n user_data=\"\",\n create_bootable_volume=False,\n assign_floating_ip=False,\n count=1)\n```\n\n\n### One-click Deployments\n\nBefore you make any deployments, ensure you have set up your environment and [ssh-key](https://infrahub-doc.nexgencloud.com/docs/network/ssh/#create-an-ssh-key) as per the Hyperstack Documentation. Please note that the one-click deployments can take 5-10 minutes to be ready after the script has completed. The script completes when the machine is ready, but the machine still needs to download the docker image with ollama or python with notebooks within it. Further details can be found below within [One-click deployment further details](#one-click-deployment-further-details) section.\n\n\n#### Deploy Ollama Server\n\nFirst set-up your ssh key and environment. Then navigate to the hyperstack library and run:\n\n```bash\nhyperstack ollama --name ollama-server --flavor_name n2-RTX-A5000x1 --key_name your-key --environment your-environment\n```\n\n\n#### Deploy Pytorch server\n\nThe same command as above, but change ollama to pytorch\n\n```bash\nhyperstack pytorch --name ollama-server --flavor_name n2-RTX-A5000x1 --key_name your-key --environment your-environment\n```\n\n\n#### Deploy from Python\n\n```python3\nfrom hyperstack.deploy import deploy\ndeploy(deployment_type=\"pytorch\", name=\"pytorch-vm\", environment=\"your-environment\", flavor_name=\"n2-RTX-A5000x1\", key_name=\"your-key\")\n```\n\n\n\n```python3\nfrom hyperstack.deploy import deploy\ndeploy(deployment_type=\"ollama\", name=\"ollama-vm\", environment=\"your-environment\", flavor_name=\"n2-RTX-A5000x1\", key_name=\"your-key\")\n```\n\n\n### One-click deployment further details\n\nHere's a sample command to run the deployment.\n\n```bash\nhyperstack pytorch --name ollama-server --flavor_name n2-RTX-A5000x1 --key_name your-key --environment your-environment\n```\n\nAfter you run a command (for example the Pytorch server), you will receive the requested configuration and useful details will print out.\n\n```bash\nEnvironment set to: your-environment\nBooting 12345\nAttempt 1/4: VM 12345 status is BUILD. Waiting for 30 seconds.\nMachine 12345 Ready\nPublic IP: xxx.xxx.xxx.xxx\nIn container credentials:\nusername: dockeruser\nPassword: xxxxxxxx\n````\n\nThis includes your virtual machine id, public ip for to ssh into the machine, and your dockeruser credentials. This will default to a uuid, unless explicitly provided.\nThe machine is ready and will now download docker, the docker image with pytorch, juptyer notebooks inside and the configuration. This will take another 5-10 minutes, but for now, you will be able to ssh into the machine:\n\n```bash\nssh -i ~/.ssh/ed25519 ubuntu@xxx.xxx.xxx.xxx\n```\n\nIf you'd like to follow the installation:\n\nOnce ssh in the machine, you can try to open the docker container. Please note: it can sometimes take 5-10 minutes for docker to install and the docker image to be downloaded after the machine is ready. Please be patient with this. If you'd like to debug this you can do the following once ssh into the machine.\n\nApply the docker group to your current shell session:\n```bash\nnewgrp docker\n```\n\nCheck that docker and the image has indeed downloaded. This may take 5-10 minutes.\n```bash\ndocker ps -a\n```\n\nOnce it has downloaded you should see output like the below:\n```\nCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\nxxxxxxxxxxxx balancedscorpion/python3-pytorch-ubuntu \"/entrypoint.sh /bin\u2026\" 2 minutes ago Up 2 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp pytorch\n```\n\nNow you can access the docker container. You can access this. For example, using VScode you can download ssh-connect and dev-containers to access this directly.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A Python wrapper for the Hyperstack API",
"version": "0.2.6",
"project_urls": {
"Homepage": "https://github.com/balancedscorpion/hyperstack",
"Repository": "https://github.com/balancedscorpion/hyperstack"
},
"split_keywords": [
"api",
" wrapper",
" hyperstack",
" gpu"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6351f072df4d168f049ec709992ed5eb02258f6ec504da85193b5669805403cc",
"md5": "b70030763ab201754b4f4beb92657f5f",
"sha256": "e633250cbdde03973318881604a9431a2454c364d485a7ebd257d27a358c4421"
},
"downloads": -1,
"filename": "hyperstack-0.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b70030763ab201754b4f4beb92657f5f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 18944,
"upload_time": "2024-08-02T08:41:09",
"upload_time_iso_8601": "2024-08-02T08:41:09.560025Z",
"url": "https://files.pythonhosted.org/packages/63/51/f072df4d168f049ec709992ed5eb02258f6ec504da85193b5669805403cc/hyperstack-0.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0f0a3ab98e62acf5537f72bb5c2370833c4e24a575d411a8fd3aac5774049300",
"md5": "7a07d3b7f131086dcb7102019dc5a253",
"sha256": "0da990c9805c3cd2509b441dcb96ba1762402d8ca6e0240241157caaab4cbba3"
},
"downloads": -1,
"filename": "hyperstack-0.2.6.tar.gz",
"has_sig": false,
"md5_digest": "7a07d3b7f131086dcb7102019dc5a253",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 15944,
"upload_time": "2024-08-02T08:41:10",
"upload_time_iso_8601": "2024-08-02T08:41:10.975370Z",
"url": "https://files.pythonhosted.org/packages/0f/0a/3ab98e62acf5537f72bb5c2370833c4e24a575d411a8fd3aac5774049300/hyperstack-0.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-02 08:41:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "balancedscorpion",
"github_project": "hyperstack",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "hyperstack"
}