Skip to main content

Official CLI for deploying and managing services on OneXERP Platform

Project description

OneXERP Platform CLI (onex)

Official CLI tool for deploying and managing services on the OneXERP Platform.

Overview

The onex CLI provides a unified interface for:

  • Deploying services to different environments (local/dev/staging/prod)
  • Validating service configurations (service.yml)
  • Invoking service functions directly
  • Tracing requests through the platform
  • Viewing service logs and status
  • Managing service resources

Installation

For Service Developers

# From onexerp-services repository root:
pip install -e ../onexerp-platform-NEW/onex-cli

# Or add to requirements.txt:
onex-cli @ file:../onexerp-platform-NEW/onex-cli

For Platform Developers

The CLI is automatically available when working in the platform repository:

# From onexerp-platform-NEW:
cd onex-cli
pip install -e .

Usage

Deploy a Service

# Deploy to local environment
onex deploy

# Deploy to specific environment
onex deploy --env dev
onex deploy --env staging
onex deploy --env prod

# Deploy from specific directory
onex deploy --service-dir ./services/product

Validate Service Configuration

# Validate service.yml without deploying
onex validate

# Validate specific service
onex validate --service-dir ./services/product

Invoke Functions

# Sync invoke (returns result immediately)
onex invoke product:calculateTotal '{"items": [...]}'

# Async invoke (fire and forget)
onex invoke --async product:processLargeFile '{"file_id": "123"}'

# Specify environment
onex invoke --env dev product:calculateTotal '{"items": [...]}'

Trace Requests

# Trace a request by trace_id
onex trace 550e8400-e29b-41d4-a716-446655440000

# Trace with environment
onex trace 550e8400-e29b-41d4-a716-446655440000 --env local

# Follow trace in real-time
onex trace 550e8400-e29b-41d4-a716-446655440000 --follow

# JSON output
onex trace 550e8400-e29b-41d4-a716-446655440000 --json

View Service Status

# Check service health and deployment status
onex status product

# Check all services
onex status

# Specify environment
onex status product --env dev

View Logs

# View service logs
onex logs product

# Follow logs in real-time
onex logs product --follow

# Last N lines
onex logs product --lines 100

Development Mode

# Run service locally with hot-reload
onex dev

# Specify service directory
onex dev --service-dir ./services/product

# Specify port
onex dev --port 8001

Initialize Configuration

# Interactive configuration setup
onex init

# Creates ~/.onex/config.yml with platform URLs and API keys

Provision Resources

# Manually provision MongoDB collections, indexes, etc.
onex provision

# Specify environment
onex provision --env dev

Configuration

The CLI uses ~/.onex/config.yml for environment-specific settings:

environments:
  local:
    platform_url: http://localhost:8000
    deployment_url: http://localhost:8002
  dev:
    platform_url: https://dev-platform.onexerp.com
    deployment_url: https://dev-platform.onexerp.com:8002
    api_key: ${ONEX_DEV_API_KEY}
  staging:
    platform_url: https://staging-platform.onexerp.com
    deployment_url: https://staging-platform.onexerp.com:8002
    api_key: ${ONEX_STAGING_API_KEY}
  prod:
    platform_url: https://platform.onexerp.com
    deployment_url: https://platform.onexerp.com:8002
    api_key: ${ONEX_PROD_API_KEY}

Service Configuration

Services must include a service.yml file:

name: product
version: 1.0.0
description: Product management service

deployment:
  mode: shared-runtime

functions:
  - name: getProduct
    handler: src.handlers.get_product
    triggers:
      - type: http
        path: /products/{id}
        method: GET

  - name: calculateTotal
    handler: src.handlers.calculate_total
    triggers: []  # Invoke-only function

  - name: processFile
    handler: src.handlers.process_file
    triggers:
      - type: s3
        bucket: product-uploads
        events: ["s3:ObjectCreated:*"]
        prefix: images/

Commands Reference

Command Description
onex init Initialize CLI configuration (interactive)
onex validate Validate service.yml schema without deploying
onex deploy Deploy service to platform
onex dev Run service locally with hot-reload
onex invoke Invoke service functions directly
onex trace Track requests through platform with trace_id
onex logs View service logs
onex status Check service status and health
onex provision Manually provision MongoDB resources

Development

Architecture

onex-cli/
├── setup.py                 # Package configuration
├── README.md               # This file
└── onex/
    ├── __init__.py
    ├── __main__.py         # CLI entry point
    ├── config.py           # Configuration management
    ├── utils.py            # Shared utilities
    ├── commands/           # Command implementations
    │   ├── deploy.py
    │   ├── trace.py
    │   ├── invoke.py
    │   ├── validate.py
    │   ├── logs.py
    │   ├── status.py
    │   ├── dev.py
    │   ├── init.py
    │   └── provision.py
    └── schema/
        ├── service_descriptor.py → ../../platform-services/shared/schema/service_descriptor.py
        └── validator.py

Adding New Commands

  1. Create command file in onex/commands/
  2. Implement using Click decorators
  3. Register in onex/__main__.py

Example:

# onex/commands/newcommand.py
import click
from onex.config import get_config
from onex.utils import print_success, print_error

@click.command()
@click.option('--env', default='local', help='Environment')
def newcommand(env):
    """Description of new command"""
    config = get_config(env)
    # Implementation here
    print_success("Command completed!")

# Register in onex/__main__.py
from onex.commands import newcommand
cli.add_command(newcommand.newcommand)

Platform Integration

The CLI integrates with these platform services:

  • Deployment Controller (8002) - Service deployment and versioning
  • Gateway (8000) - HTTP routing and function invocation
  • Loki (3100) - Log aggregation and trace queries
  • Service Registry (8500) - Service discovery and health checks

Schema Validation

The CLI uses the platform's official schema from:

platform-services/shared/schema/service_descriptor.py

This ensures service configurations are validated against the same schema used by the deployment controller.

Troubleshooting

Command not found: onex

# Reinstall CLI in editable mode
pip install -e /path/to/onexerp-platform-NEW/onex-cli

# Verify installation
which onex
onex --version

Import errors

The CLI imports schema definitions from the platform. Ensure the platform repository is available:

# The symlink should exist:
ls -la onex-cli/onex/schema/service_descriptor.py
# → points to ../../platform-services/shared/schema/service_descriptor.py

Deployment failures

# Validate service.yml first
onex validate

# Check platform health
onex status --env local

# View deployment logs
onex logs deployment-controller

License

MIT License - See platform repository for details.

Support

  • Platform Developers: Update CLI in onexerp-platform-NEW/onex-cli/
  • Service Developers: Install CLI via pip install -e ../onexerp-platform-NEW/onex-cli
  • Issues: Report in platform repository

Related Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onex_cli-1.0.0.tar.gz (67.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onex_cli-1.0.0-py3-none-any.whl (77.6 kB view details)

Uploaded Python 3

File details

Details for the file onex_cli-1.0.0.tar.gz.

File metadata

  • Download URL: onex_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 67.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for onex_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 58953a2aa1152ed65b74d9a91b722381d98da95527808b1a8b97ab32b90e7855
MD5 df4db171c4485cb96dc96640de36163e
BLAKE2b-256 52ef72c47b605046dcd3b75a7d57b53fdc68271364d8a823d304575509ecfdb5

See more details on using hashes here.

File details

Details for the file onex_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: onex_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 77.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for onex_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be0648d3b6e541c033bc20150b22bb99e4b0e753319dec0541bbd6ff60e89baf
MD5 1238008c6d04211c4fd9837792727309
BLAKE2b-256 d0f4e3e5d7fc9a120944d4ec2cbe8c7f570bab4b852c7a41f14190d4d1c7a98c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page