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-2.0.0.tar.gz (118.3 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-2.0.0-py3-none-any.whl (144.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for famou_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9180e4e2668e21ebf5aa41bdc54157c72e3a7a93631118966f8844c71e9671ef
MD5 9dcbfc3efa48cbd481e1d0bf422acf4a
BLAKE2b-256 510f6b186aed377877d60965ed50016b1244e580af8c7e445ced2041a3672eb1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: famou_sdk-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 144.4 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-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5bae6cfffd49eac228eb02b0392fa2fa0931a856cc3e0f455d5b7afa22a55e9
MD5 053312d8301ad8438c8e31db96fca695
BLAKE2b-256 24a2761890eeb8337ab5f4f562f11ea990172e6b5683bb4b7638eae037bc32f8

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