Skip to main content

Agenlus Python Hub Client (agenlus-hub)

PyPI version Python versions License: MIT

agenlus-hub is the official Python client library for the Agenlus RL Platform. It provides a seamless interface to download custom RL environments, run local evaluations on your PyTorch models, and automatically export, build, upload, and register them onto the Agenlus leaderboards.


Key Features

  • Simple Authentication: Quick setup with single-line token authentication.
  • Environment Downloader: Easily fetch custom Gymnasium environment specifications and source code directly from the server.
  • Automatic Export & SB3 Support: Exposes models (both pure PyTorch and stable-baselines3 models) to both PyTorch (.pt) and ONNX (.onnx) formats with dynamic batching.
  • Deterministic Evaluation: Validates model performance locally using reproducible seeds before uploading.
  • Hugging Face Hub Integration: Automates repositories creation and stacks model uploads into tidy subfolders.
  • Leaderboard Registration: Instant, automated registration of evaluated models to the Agenlus leaderboard.

Installation

Install the package and its dependencies via pip:

pip install agenlus-hub

Dependencies

Ensure you have the following prerequisites installed (or they will be installed automatically):

  • requests
  • torch
  • onnx
  • onnxscript
  • huggingface_hub
  • gymnasium (Required for local model evaluation)

Quick Start

Here is a quick walkthrough showing how to log in, download an environment, build/train your model, and upload it to the leaderboard:

import torch
import torch.nn as nn
import agenlus

# 1. Log in to your Agenlus account
agenlus.login(token="YOUR_AGENLUS_API_TOKEN")

# 2. Download the target environment (e.g., CartPole-v1)
# This downloads 'CartPole-v1.py' into your working directory
env_file_path = agenlus.download("system/CartPole-v1")

# 3. Define and train your PyTorch RL Model
class PolicyNet(nn.Module):
    def __init__(self, obs_dim=4, action_dim=2):
        super().__init__()
        self.fc = nn.Sequential(
            nn.Linear(obs_dim, 128),
            nn.ReLU(),
            nn.Linear(128, action_dim)
        )
        
    def forward(self, x):
        return self.fc(x)

# Instantiate your model (or load from disk)
model = PolicyNet()

# 4. Evaluate and Upload to Agenlus & Hugging Face
# This evaluates the model for 100 episodes, exports to ONNX/PyTorch, 
# uploads to Hugging Face, and registers the scores on the Leaderboard.
agenlus.upload(
    model=model,
    env_id="system/CartPole-v1",
    hf_token="YOUR_HUGGINGFACE_WRITE_TOKEN",
    model_name="my-first-cartpole-agent",
    seed=42
)

Stable-Baselines3 Support (DQN, PPO, SAC, etc.)

You can directly upload models trained with stable-baselines3. The policy network will be automatically wrapped and exported to ONNX:

import gymnasium as gym
from stable_baselines3 import DQN
import agenlus

# 1. Log in
agenlus.login(token="YOUR_AGENLUS_API_TOKEN")

# 2. Download environment code (if custom or needed)
env_file = agenlus.download("system/CartPole-v1")

# 3. Define and train your SB3 agent
env = gym.make("CartPole-v1")
model = DQN("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10000)

# 4. Upload and register to Leaderboard
# This automatically wraps model.q_net (DQN) / model.policy (PPO) for ONNX compatibility
agenlus.upload(
    model=model,
    env_id="system/CartPole-v1",
    hf_token="YOUR_HUGGINGFACE_WRITE_TOKEN",
    model_name="my-sb3-dqn-agent",
    seed=42
)

API Reference

agenlus.login

Authenticates your local client session.

agenlus.login(token: str, api_url: str = None)
  • token (str): Your Agenlus developer API token.
  • api_url (str, optional): Overrides the default platform backend URL.

agenlus.download

Downloads the source code of an environment registered on the platform.

save_path = agenlus.download(env_id: str, save_path: str = None)
  • env_id (str): The ID of the environment (e.g., system/CartPole-v1 or username/custom-env).
  • save_path (str, optional): Custom file path to save the code. Defaults to {env_name}.py in the current directory.
  • Returns: The path to the saved file.

agenlus.upload

Executes local evaluation, model export, Hugging Face upload, and platform leaderboard registration.

agenlus.upload(
    model,
    env_id: str,
    hf_token: str,
    hf_repo: str = None,
    model_name: str = None,
    seed: int = None
)
  • model (PyTorch model or stable-baselines3 model): The trained RL model (e.g., a PyTorch nn.Module or a stable_baselines3 agent). If a stable-baselines3 model is provided, its policy network is automatically wrapped and extracted.
  • env_id (str): Target environment ID on the platform.
  • hf_token (str): Write access token for Hugging Face.
  • hf_repo (str, optional): The Hugging Face repo (e.g., username/repo-name). If omitted, checks your profile settings or defaults to username/agenlus-agents.
  • model_name (str, optional): Unique name for this model checkpoint. Subdirectories under the repository will be structured around this name.
  • seed (int, optional): Seed used to ensure deterministic environment evaluation. (Default: 42).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for agenlus-hub 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agenlus-hub 0.2.7
File Size Uploaded Provenance Actions
agenlus_hub-0.2.7.tar.gz 12.3 kB Without provenance Details for agenlus_hub-0.2.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agenlus-hub 0.2.7
File Interpreter ABI Platform Actions
agenlus_hub-0.2.7-py3-none-any.whl Python 3 none any Details for agenlus_hub-0.2.7-py3-none-any.whl

Total release size: 22.4 kB

Release files / agenlus_hub-0.2.7.tar.gz

Download URL agenlus_hub-0.2.7.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e4f4db5155f22bdf1d2f2c6027a4f8179c1fe6cf25ce17404a24013924a3b14a
BLAKE2b-256 checksum
How to use checksums
3653b4b0ecd5a65c531075d4026eb22198db6adfc507aac37bb050b11da1cafd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / agenlus_hub-0.2.7-py3-none-any.whl

Download URL agenlus_hub-0.2.7-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb84f7e4ff1810f1333ae17d0b905f54ba5a479fe241ea759eaa417c3f03ccc7
BLAKE2b-256 checksum
How to use checksums
0842d62242fb9e664c8b0f196699acd63bcb5262319347333c69bd6093272e9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for agenlus-hub 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page