Repository navigation
Expand file tree
/
Copy pathquickstart.py
More file actions
71 lines (57 loc) · 2.74 KB
/
Copy pathquickstart.py
File metadata and controls
71 lines (57 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
"""Quickstart: Generate a video, persist to Backblaze B2, verify provenance.
End-to-end example — mirrors the Quickstart in the repo README. Generates
a video via GMICloud (Seedance 2.0 — ByteDance's latest multimodal video
model), uploads the asset and its provenance manifest to Backblaze B2,
and prints the durable URLs plus SHA-256 integrity verification.
Usage:
pip install genblaze-core genblaze-gmicloud genblaze-s3
export GMI_API_KEY="gmi-..."
export B2_KEY_ID="..."
export B2_APP_KEY="..."
python examples/quickstart.py
Replace "my-bucket" below with the name of a B2 bucket you own. The
backend auto-detects the bucket's region on first use, so passing
``region=`` is just an optimization hint (default ``us-west-004``).
If your bucket lives in ``us-east-005`` or ``eu-central-003``, pass
it explicitly to skip the redirect round-trip.
For a simpler demo without any API keys, see quickstart_local.py.
"""
from genblaze_core import KeyStrategy, Modality, ObjectStorageSink, Pipeline
from genblaze_gmicloud import GMICloudVideoProvider
from genblaze_s3 import S3StorageBackend
# Progress is shown automatically by Pipeline.run() when stderr is a TTY —
# a compact spinner with provider:model and elapsed time. Opt out with
# ``.run(progress=False)``, or pass your own ``on_progress=`` callback.
def main() -> None:
storage = ObjectStorageSink(
# Default region is us-west-004. Override with region="us-east-005"
# (or whatever region your bucket was created in) to skip the
# one-time redirect when the hint doesn't match.
# auto_lifecycle=True opts in to recommended lifecycle rules
# (cancel orphaned multipart uploads, expire noncurrent versions);
# default in 0.3.0+ is False so callers managing lifecycle
# out-of-band aren't surprised by hidden bucket mutations.
S3StorageBackend.for_backblaze("my-bucket", auto_lifecycle=True),
key_strategy=KeyStrategy.HIERARCHICAL,
)
result = (
Pipeline("my-first-pipeline")
.step(
GMICloudVideoProvider(),
model="seedance-2-0-260128",
prompt="A drone shot soaring over a coastal city at golden hour",
modality=Modality.VIDEO,
duration=10,
aspect_ratio="16:9",
)
.run(sink=storage, timeout=600)
)
asset = result.run.steps[0].assets[0]
print(f"Asset URL: {asset.url}") # B2 durable URL — no signature, never expires
print(f"SHA-256: {asset.sha256}")
print(f"Manifest: {result.manifest.manifest_uri}") # Provenance JSON in B2
print(f"Hash: {result.manifest.canonical_hash}")
print(f"Verified: {result.manifest.verify()}")
if __name__ == "__main__":
main()