pyperf is incompatible with click
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
click 7.1.1 と pyperf 2.0.0 を使って issue の最小再現スクリプトを実行し、その後 argparse が使われている pyperf/_runner.py の 126-129 行付近を調べます。click コマンド内で Runner が呼び出されたときに、Runner が引数をどのように処理するかを追跡します。再現時に --worker などの pyperf オプションが click に渡されなくなり、意図した benchmark の呼び出しが引き続きサポートされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
When a script calls pyperf.Runner.bench_func from a script that uses click to handle arguments, it raises an exception in pyperf's argument parsing logic. Here is a minimal reproducing script:
import click
import pyperf
@click.command()
def cli():
def f():
pass
runner = pyperf.Runner()
runner.bench_func("Example", f)
if __name__ == "__main__":
cli()
Here's a requirements.txt, pinned to the versions I have tried this with:
click==7.1.1
pyperf==2.0.0
The error message is:
$ python my_benchmark.py
Usage: my_benchmark.py [OPTIONS]
Try 'my_benchmark.py --help' for help.
Error: no such option: --worker
I believe that the issue is that pyperf.Runner is directly using argparse to add its own command line arguments, which is not really the behavior I would expect from a library.
It might be a lot to ask, but I think a better option would be to refactor this into a config object that can also be constructed automatically from the parser, something like this:
import attr
@attr.s(auto_attrib=True)
class RunnerConfig:
verbose: bool = False
quiet: bool = False
pipe: int = None
...
@classmethod
def from_argparse(cls, argparser=None):
if argparser is None:
argparser = argparse.ArgumentParser()
parser.description = "Benchmark"
....
args = argparser.parse_args()
return cls(verbose=args.verbose, quiet=args.quiet, pipe=args.pipe, ...)
To avoid backwards incompatibility issues, you can add a flag to Runner like use_argparse=True, which users of click could set to False to avoid this problem.
- 主要言語
- Python
- スター
- 967
- フォーク
- 112
- 平均マージ
- 5日 8時間
- マージ済み PR(30日)
- 9
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
psf/pyperf のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Improve Type System for `pyperf`対応中かも @DebanKsahu が 69 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 32/100
メンテナーはふだん 1 日以内に返信
-
Extend hook's teardown metadata with warmup/calibration flags対応中かも @maurycy が 170 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
add entry to blockオープン
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
StevenBlack/hosts#3299 ·
-
`garak --report` overwrites the input report when its name has no ".report"対応中かも @0z5a が今日担当しました。 オープンneeds-triage
難易度 2/5 半日 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信
-
plot_graph crashes when a mesh node has no m2m edge対応中かも @tygvi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mllam/neural-lam#883 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
future-agi/future-agi#4092 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
transcript analytics: a text whose only protected spans the prose pass redacts is withheld wholeオープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
WingedGuardian/GENesis-AGI#4641 ·
メンテナーはふだん 1 日以内に返信