Skip to main content

Famou OpenAPI Python SDK

Project description

Famou SDK

Famou OpenAPI 的 Python SDK,提供同步/异步客户端和命令行工具。

安装

pip install famou-sdk

快速开始

同步客户端

from famou_sdk import FamouClient

client = FamouClient(
    endpoint="https://famou.example.com",
    api_key="your-api-key"
)

# 1. 上传物料包
pkg = client.package_create(
    file_path="./data.tar.gz",
    upload_mode="full"
)
print(f"File ID: {pkg.data.file_id}")

# 2. 创建实验
exp = client.experiment_create(
    name="my-experiment",
    file_id=pkg.data.file_id
)
print(f"Experiment ID: {exp.data.exp_id}")

# 3. 查看实验状态
info = client.experiment_info(exp.data.exp_id)
print(f"Status: {info.data.status}")

异步客户端

import asyncio
from famou_sdk import AsyncFamouClient

async def main():
    async with AsyncFamouClient(
        endpoint="https://famou.example.com",
        api_key="your-api-key"
    ) as client:
        pkg = await client.package_create("./data.tar.gz", "full")
        exp = await client.experiment_create("my-exp", pkg.data.file_id)
        info = await client.experiment_info(exp.data.exp_id)
        print(f"Status: {info.data.status}")

asyncio.run(main())

API

初始化参数

参数 类型 说明
endpoint str API 服务端点
api_key str API 密钥
timeout float 请求超时(秒),默认 30.0

物料包管理

方法 说明
package_create(file_path, upload_mode, file_id?, delete_files?) 新建/更新物料包(仅支持 tar.gz)
package_info(file_id) 查询物料包详情
package_list() 列出所有物料包

实验管理

方法 说明
experiment_create(name, file_id) 创建实验
experiment_update(exp_id, name, file_id) 更新实验
experiment_info(exp_id) 获取实验详情
experiments_list() 列出所有实验
experiment_pause(exp_id) 暂停实验
experiment_resume(exp_id) 继续实验
experiment_cancel(exp_id) 取消实验
experiment_delete(exp_id) 删除实验
experiment_report(exp_id) 获取实验报告下载地址
experiment_result(exp_id) 获取最优解下载地址
experiment_log(exp_id, playback?, timeout?) 获取实验日志(SSE 流式)
experiment_log_to_file(exp_id, output_path, playback?, timeout?) 日志保存到文件

评测管理

方法 说明
evaluation_create(evaluation_id, exp_id, code, dependencies?, iteration?, timeout?) 创建评测任务
evaluation_get(evaluation_id, exp_id) 获取评测任务详情
evaluation_assign(exp_id, evaluator?, max_count?) 分配评测任务
evaluation_submit_result(evaluators) 提交评测结果

认证

方法 说明
login() 登录认证

错误处理

from famou_sdk import FamouAPIError

try:
    client.experiment_info("exp-xxx")
except FamouAPIError as e:
    print(f"Error: {e.code} - {e.message}")

日志设置

from famou_sdk import set_log_level

# 设置日志级别,可选值: DEBUG, INFO, WARNING, ERROR, CRITICAL
set_log_level("DEBUG")  # 输出详细调试信息
set_log_level("INFO")   # 输出一般信息
set_log_level("WARNING")  # 默认级别,仅输出警告和错误

CLI 工具

安装后自动创建 famou-ctl 命令。

# 登录认证
famou-ctl login

# 初始化项目
famou-ctl init my-project

# 本地测试
famou-ctl test --config config.yaml

# 物料包管理
famou-ctl package create ./project
famou-ctl package upload ./package.tar.gz
famou-ctl package info <package_id>

# 实验管理
famou-ctl experiment create --config ./project/config.yaml --experiment-name my-exp
famou-ctl experiment list
famou-ctl experiment status <exp_id>
famou-ctl experiment pause <exp_id>
famou-ctl experiment resume <exp_id>
famou-ctl experiment cancel <exp_id>
famou-ctl experiment delete <exp_id>
famou-ctl experiment update <exp_id> --config config.yaml
famou-ctl experiment logs <exp_id>
famou-ctl experiment results <exp_id>
famou-ctl experiment report <exp_id>

# 混合云评测
famou-ctl evaluator start --experiment-id <exp_id> --evaluator-path ./evaluator.py

# 升级
famou-ctl upgrade

# 登出
famou-ctl logout

许可证

Apache License 2.0

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

famou_sdk-1.1.1.tar.gz (103.6 kB view details)

Uploaded Source

Built Distribution

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

famou_sdk-1.1.1-py3-none-any.whl (129.9 kB view details)

Uploaded Python 3

File details

Details for the file famou_sdk-1.1.1.tar.gz.

File metadata

  • Download URL: famou_sdk-1.1.1.tar.gz
  • Upload date:
  • Size: 103.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for famou_sdk-1.1.1.tar.gz
Algorithm Hash digest
SHA256 ef5b3fd82a89e4f7e15021c057a129b6f551efe619b9b8ef98f8684e4e2471ee
MD5 c6bce74b739925d9ce5dec21b02bc55c
BLAKE2b-256 e423284e75c986ed1d510e77f238c8076b0cda6cb81d0e1fdabf9054f5fbe3f3

See more details on using hashes here.

File details

Details for the file famou_sdk-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: famou_sdk-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 129.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for famou_sdk-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bef94794a58500a313b61d16d82ce4adb6e5976b951ac496ec96ef30cc783414
MD5 7f8019d7ad1f1b0030ce04de4d209bda
BLAKE2b-256 65f60cf07b7bb71fdb9fdad12908ad5a573a0feb61a9e6bdb4ea081a5cb6b0d4

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