PrimeHub
  • Introduction
  • Installation
  • Tiers and Licenses
  • End-to-End Tutorial
    • 1 - MLOps Introduction and Scoping the Project
    • 2 - Train and Manage the Model
    • 3 - Compare, Register and Deploy the Model
    • 4 - Build the Web Application
    • 5 - Summary
  • User Guide
    • User Portal
    • Notebook
      • Notebook Tips
      • Advanced Settings
      • PrimeHub Notebook Extension
      • Submit Notebook as Job
    • Jobs
      • Job Artifacts
      • Tutorial
        • (Part1) MNIST classifier training
        • (Part2) MNIST classifier training
        • (Advanced) Use Job Submission to Tune Hyperparameters
        • (Advanced) Model Serving by Seldon
        • Job Artifacts Simple Usecase
    • Models
      • Manage and Deploy Model
      • Model Management Configuration
    • Deployments
      • Pre-packaged servers
        • TensorFlow server
        • PyTorch server
        • SKLearn server
        • Customize Pre-packaged Server
        • Run Pre-packaged Server Locally
      • Package from Language Wrapper
        • Model Image for Python
        • Model Image for R
        • Reusable Base Image
      • Prediction APIs
      • Model URI
      • Tutorial
        • Model by Pre-packaged Server
        • Model by Pre-packaged Server (PHFS)
        • Model by Image built from Language Wrapper
    • Shared Files
    • Datasets
    • Apps
      • Label Studio
      • MATLAB
      • MLflow
      • Streamlit
      • Tutorial
        • Create Your Own App
        • Create an MLflow server
        • Label Dataset by Label Studio
        • Code Server
    • Group Admin
      • Images
      • Settings
    • Generate an PrimeHub API Token
    • Python SDK
    • SSH Server Feature
      • VSCode SSH Notebook Remotely
      • Generate SSH Key Pair
      • Permission Denied
      • Connection Refused
    • Advanced Tutorial
      • Labeling the data
      • Notebook as a Job
      • Custom build the Seldon server
      • PrimeHub SDK/CLI Tools
  • Administrator Guide
    • Admin Portal
      • Create User
      • Create Group
      • Assign Group Admin
      • Create/Plan Instance Type
      • Add InfuseAI Image
      • Add Image
      • Build Image
      • Gitsync Secret for GitHub
      • Pull Secret for GitLab
    • System Settings
    • User Management
    • Group Management
    • Instance Type Management
      • NodeSelector
      • Toleration
    • Image Management
      • Custom Image Guideline
    • Volume Management
      • Upload Server
    • Secret Management
    • App Settings
    • Notebooks Admin
    • Usage Reports
  • Reference
    • Jupyter Images
      • repo2docker image
      • RStudio image
    • InfuseAI Images List
    • Roadmap
  • Developer Guide
    • GitHub
    • Design
      • PrimeHub File System (PHFS)
      • PrimeHub Store
      • Log Persistence
      • PrimeHub Apps
      • Admission
      • Notebook with kernel process
      • JupyterHub
      • Image Builder
      • Volume Upload
      • Job Scheduler
      • Job Submission
      • Job Monitoring
      • Install Helper
      • User Portal
      • Meta Chart
      • PrimeHub Usage
      • Job Artifact
      • PrimeHub Apps
    • Concept
      • Architecture
      • Data Model
      • CRDs
      • GraphQL
      • Persistence Storages
      • Persistence
      • Resources Quota
      • Privilege
    • Configuration
      • How to configure PrimeHub
      • Multiple Jupyter Notebook Kernels
      • Configure SSH Server
      • Configure Job Submission
      • Configure Custom Image Build
      • Configure Model Deployment
      • Setup Self-Signed Certificate for PrimeHub
      • Chart Configuration
      • Configure PrimeHub Store
    • Environment Variables
Powered by GitBook
On this page
  • Introduction
  • Prerequisites
  • End-to-end Step
  • Reference
  1. User Guide
  2. Advanced Tutorial

PrimeHub SDK/CLI Tools

Introduction

PrimeHub Python SDK is the PrimeHub AI Platform Software Development Kit (SDK) for Python, allowing Python developers to write software that uses services like Job and Deployment.

Prerequisites

Assuming that you have Python, you can install the library using pip:

$ pip install primehub-python-sdk

Or try the latest from our source code:

$ pip install git+https://github.com/InfuseAI/primehub-python-sdk.git@main

End-to-end Step

Step 1: Initial the PrimeHub CLI/SDK

PRIMEHUB_CLUSTER = <PrimeHub-cluster-url>

import os
from primehub import PrimeHub, PrimeHubConfig
ph = PrimeHub(PrimeHubConfig())
ph.config.generate(PRIMEHUB_CLUSTER)

ph.config.set_group(<group-name>)

Step 2: Get the authorization code

If you see the content that want us to insert the authorization code, please click the url to get the token.

Step 3: Check the group information

if ph.is_ready():
    print("PrimeHub Python SDK setup successfully")
    print("Current Group:", ph.primehub_config.current_group)
else:
    print("PrimeHub Python SDK couldn't get the group information, please check the configuration.")
Current Group: {'id': <group-id>, 'name': 'InfuseAI', 'displayName': 'InfuseAI'}

Step 4: Use Primehub python SDK to submit the PrimeHub job.

# Submit a job
config = {
    "instanceType": "cpu-1",
    "image": "base-notebook",
    "displayName": "PrimeHub SDK: Model Training",
    "command": "echo 'We can do the model training in PrimeHub Jobs.'",
}

short_job = ph.jobs.submit(config)
print(short_job)

Step 5: Submit the job

Submit the job and check the logs.

# Wait the job to be done
print('[ Waiting ]')
ph.jobs.wait(short_job['id'])
print('[ Job Done ]')

# Get logs
logs = ph.jobs.logs(short_job['id'])
print('[ Job Logs ]')
for l in logs:
    print(l)

You can use other python SDK methods to control the PrimeHub. This tool can help you build an automatic ML pipeline with CI/CD pipeline.

Reference

PreviousCustom build the Seldon serverNextAdmin Portal

Last updated 2 years ago

GitHub:

InfuseAI/primehub-python-sdk