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.0.tar.gz (103.0 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.0-py3-none-any.whl (129.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: famou_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 103.0 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.0.tar.gz
Algorithm Hash digest
SHA256 eafa90bc95a255f3f03746da59d621ab14bb37d6c1396cd398996b7796deb662
MD5 6fe62f2922a92080c8153b950845749a
BLAKE2b-256 dd12afb60ea678eb671be444d1d661ff1f293f6b0d92093343cf87b7278a7936

See more details on using hashes here.

File details

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

File metadata

  • Download URL: famou_sdk-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 129.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e13dfc0aa2cbe70685cebb994529f141a06451b41e817eac89f6f75e8fca9e2f
MD5 e1ccddfba2dd4d5dcff7c8f37c1295d7
BLAKE2b-256 f727a8791b5972d75910f6c0b074b74e93d6284ef24e35b54a8a7ef7e0e15439

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