Skip to main content

No project description provided

Project description

ygo

并发执行(加入进度条)以及延迟调用(基于joblib),以及获取对应函数的相关信息

安装

pip install -U git+https://github.com/link-yundi/ygo.git

示例

├── a
│   ├── __init__.py
│   └── b
│       ├── __init__.py
│       └── c.py
└── test.py

c.py 中定义了目标函数
def test_fn(a, b=2):
    return a+b

场景1: 并发

import ygo
import ylog
from a.b.c import test_fn

with ygo.pool(job_name="test parallel", show_progress=True) as go:
    for i in range(10):
        go.submit(test_fn)(a=i, b=2*i)
    for res in go.do():
        ylog.info(res)

场景2: 延迟调用

>>> fn = delay(test_fn)(a=1, b=2)
>>> fn()
3
>>> # 逐步传递参数
>>> fn1 = delay(lambda a, b, c: a+b+c)(a=1)
>>> fn2 = delay(fn1)(b=2)
>>> fn2(c=3)
6
>>> # 参数更改
>>> fn1 = delay(lambda a, b, c: a+b+c)(a=1, b=2)
>>> fn2 = delay(fn1)(c=3, b=5)
>>> fn2()
9

场景3: 获取目标函数信息

>>> ygo.fn_info(test_fn)
=============================================================
    a.b.c.test_fn(a, b=2)
=============================================================
    def test_fn(a, b=2):
    return a+b

场景4: 通过字符串解析函数并执行

>>> ygo.fn_from_str("a.b.c.test_fn")(a=1, b=5)
6

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

ygo-1.0.7.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

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

ygo-1.0.7-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file ygo-1.0.7.tar.gz.

File metadata

  • Download URL: ygo-1.0.7.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for ygo-1.0.7.tar.gz
Algorithm Hash digest
SHA256 5c86ddaf4ad14a10d1aeb98f0bf1e66d1024c7a2df96b98caa84de5087aa2588
MD5 e21d866474355ec070b62a10f931570f
BLAKE2b-256 6373dacf1ecffddfe4d02ec899180a5210af59a3b079219544cf55dc7280a54a

See more details on using hashes here.

File details

Details for the file ygo-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: ygo-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 31.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for ygo-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a5c6a4d923bbc155eb434d27278e1916263c759d4e3f69da42c26016e3adc67b
MD5 4ea1cf597d3e49fa07afb6281a2bf5b0
BLAKE2b-256 f10cc5de65e56164cd525669c56d9da53276e0d49854b7a5c90d30aff0455ae0

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