技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
beam-and-performance【数据与研究】Scale TensorFlow Datasets generation and reading with Beam, storage, sharding, GCS, and performance controls.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the task is to scale TensorFlow Datasets (TFDS) dataset
preparation or reading with Apache Beam, cloud runners, file formats, sharding,
GCS data directories, or tf.data performance controls.
Route other work away:
tfds.load, split syntax, metadata inspection, NumPy/DataFrame, and
non-Beam loading recipes -> data-loading.tfds CLI syntax outside Beam/file-format/sharding flags ->
cli-workflows.GeneratorBasedBuilder datasets, _info, features,
checksums, dummy data, and DatasetBuilderTestCase -> dataset-authoring.formats-and-community.The TFDS code and environment verification for this skill established these runtime facts:
tfds.download.DownloadConfig fields
including beam_runner, beam_options, max_examples_per_split,
num_shards, min_shard_size, max_shard_size, and
nondeterministic_order.tfds build --beam_pipeline_options=... stores a comma-separated options
string; TFDS turns each key=value segment into a Beam PipelineOptions flag
without launching Beam during parsing.tfrecord, array_record,
riegeli, and parquet; TFRecord is the default. Some formats require extra
reader/writer dependencies or different reading APIs.tfds.core.BeamBasedBuilder still exists but is deprecated; current Beam
authoring should normally use GeneratorBasedBuilder whose
_generate_examples returns a Beam PTransform/PCollection.tfds.beam.ReadFromTFDS reads an already prepared TFDS dataset inside a Beam
pipeline, parallelizing over dataset shards.| User intent | Use |
|---|---|
| "Build this huge TFDS dataset locally just to test the builder" | Direct/local Beam runner plus a tiny --max_examples_per_split or programmatic DownloadConfig(max_examples_per_split=...); warn that full local builds can exceed RAM/disk/time. |
| "Run TFDS generation on Dataflow" | Build a GCS-backed data_dir, staging_location, temp_location, requirements_file, and runner=DataflowRunner; verify project/bucket/credentials before launch. |
| "Use Flink" | Pass runner=FlinkRunner plus Flink version/config-dir options; verify Beam/Flink version compatibility externally. |
| "Use TFDS as source inside Beam" | Use tfds.beam.ReadFromTFDS(builder, split=...) only after the dataset is prepared; respect subsplit/batch limitations. |
| "Improve reading throughput/RAM" | Tune ReadConfig, shuffling, cache/batch/prefetch order, decode/skipped features, file format, and GCS locality. |
| "Change shard count/size or file format" | Use generation flags or DownloadConfig/download_and_prepare(file_format=...); validate reader compatibility before rebuilding. |
gs://.../tensorflow_datasets root and use a GCS temp
and staging area.scripts/beam_options_helper.py to create
or validate --beam_pipeline_options strings and get warnings without
launching Beam.references/beam-workflows.md for CLI and
programmatic examples.nondeterministic_order=True or
--nondeterministic_order only when faster unordered output is acceptable
and downstream code never depends on example order.references/performance-and-storage.md
for --file_format, --num_shards, --max_shard_size_mb, and
DownloadConfig equivalents.shuffle_files=True for large
training datasets, tune ReadConfig for distributed workers and memory, skip
unused or expensive features, and benchmark the final pipeline.references/troubleshooting.md for Beam,
GCS, sharding, determinism, and performance symptoms.Local smoke only:
tfds build DATASET[/CONFIG] \
--max_examples_per_split=10 \
--data_dir=/tmp/tfds-smoke
Dataflow option construction without launching a job:
python scripts/beam_options_helper.py \
--runner DataflowRunner \
--dataset DATASET \
--project GCP_PROJECT \
--gcs-bucket gs://BUCKET \
--requirements-file /tmp/beam_requirements.txt \
--print-build-command
Programmatic generation:
import apache_beam as beam
import tensorflow_datasets as tfds
flags = [
"--runner=DataflowRunner",
"--project=GCP_PROJECT",
"--staging_location=gs://BUCKET/binaries",
"--temp_location=gs://BUCKET/temp",
"--requirements_file=/tmp/beam_requirements.txt",
]
download_config = tfds.download.DownloadConfig(
beam_options=beam.options.pipeline_options.PipelineOptions(flags=flags),
# Only set when unordered output is acceptable:
# nondeterministic_order=True,
)
builder = tfds.builder("DATASET/CONFIG", data_dir="gs://BUCKET/tensorflow_datasets")
builder.download_and_prepare(download_config=download_config)
For this sub-skill, safe verification should avoid full downloads and cloud job launches unless the user explicitly grants budget and credentials. Prefer:
python scripts/beam_options_helper.py --help and representative option
construction checks.tfds.download.DownloadConfig, tfds.ReadConfig,
and tfds.beam.ReadFromTFDS in an environment that has the required optional
packages.