Draft: Chunk up large orders in planet orders request
まだ誰も着手していません。
評価
調査の方向性
Start with the planet data search, planet orders request, and planet orders create entry points described in the issue, then review the demonstrated ml.py chunking flow. Done means large order input is split into chunks and planet orders create accepts the resulting multiline output, with the command-line behavior and UI worked out.
索引モデルが issue の本文から書いたものです。
説明
Chunk up large orders in planet orders request directly from a search.
Note: planet orders create would also have to be able to take in multiline input, as planet orders request would now output one line for each order chunk. How to do it is already demonstrated, we just have to work out the UI.
The script below is a slight alteration of the example script in #944. It demonstrates how to do a version of this:
$> planet data search --limit 500 PSScene | python ml.py --items - --chunksize=300
500
chunk: 300
chunk: 200
ml.py
import json
import click
class MultiJSON(click.ParamType):
name = 'MultiJSON'
def convert(self, value, param, ctx) -> list:
if isinstance(value, list):
conv = value
else:
# read from raw json
# skip this if value is a Path object or something else
if isinstance(value, str) and (value.startswith('{')
or value.startswith('[')):
print('hereh')
try:
conv = json.loads(value)
if isinstance(conv, dict):
conv = [conv]
except json.decoder.JSONDecodeError:
self.fail(
'JSON string is not valid JSON. Make sure the entire '
'JSON string is single-quoted and string entries are '
'double-quoted.')
# read from stdin or file
else:
try:
with click.open_file(value) as f:
conv = [json.loads(line) for line in f if line]
except FileNotFoundError:
self.fail('File not found.')
except json.decoder.JSONDecodeError:
stream = 'stdin' if value == '-' else 'JSON file'
self.fail(f'{stream} does not contain valid JSON.')
if not len(conv):
self.fail('JSON cannot be empty.')
return conv
@click.command()
@click.option('--items', type=MultiJSON(), required=True)
@click.option('--chunksize', type=int, default=5)
def hello(items, chunksize):
click.echo(len(items))
# https://stackoverflow.com/a/312464
def chunks(lst, n):
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]
for chunk in chunks(items, chunksize):
click.echo(f'chunk: {len(chunk)}')
if __name__ == '__main__':
hello()
- 主要言語
- Python
- スター
- 300
- フォーク
- 100
- 平均マージ
- 6日 18時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
planetlabs/planet-client-python のほかの issue
-
DataClient.wait_asset raises "Maximum number of attempts reached" when the last poll returns an active asset対応中かも @sebxt が 17 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
planetlabs/planet-client-python#1232 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
planetlabs/planet-client-python#1230 ·
-
better-testing
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
planetlabs/planet-client-python#1110 ·
-
Broken examples in order_request and subscription_request docstrings, async SDK guide and CLI tipsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
planetlabs/planet-client-python#1231 ·
-
FeaturesClient list_items does not support filtering対応中かも @steps-re が 121 日前に担当しました。 オープンproposal
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
planetlabs/planet-client-python#1221 ·
planetlabs/planet-client-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
jejjohnson/gaussx#752 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4270 ·
-
enhancement owner: den-haag
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ok-oldking/ok-wuthering-waves#1828 ·
メンテナーはふだん 1 日以内に返信
-
lesson-submission pending-review
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
Ikalus1988/MisakaNet#4512 ·
メンテナーはふだん 1 日以内に返信