55
66- ** Snapshots** capture the state of an entire bucket at a specific point in
77 time.
8- - ** Forks** let you branch a bucket into a new one , reusing objects without
8+ - ** Forks** let you branch a snapshot of a bucket , reusing objects without
99 copying data.
1010
1111Together, they provide powerful tools for data recovery, branching workflows, AI
@@ -23,9 +23,15 @@ function.
2323``` ts
2424import { createBucket } from " @tigrisdata/storage" ;
2525
26- await createBucket (" llm-base" , {
26+ const result = await createBucket (" llm-base" , {
2727 enableSnapshot: true ,
2828});
29+
30+ if (result .error ) {
31+ console .error (" error creating bucket" , result .error );
32+ } else {
33+ console .log (" bucket created with snapshots enabled" );
34+ }
2935```
3036
3137## Snapshots
@@ -38,28 +44,7 @@ function.
3844``` ts
3945import { createBucketSnapshot } from " @tigrisdata/storage" ;
4046
41- await createBucketSnapshot (' llm-base' , {
42- description: " pre-finetune" ,
43- });
44-
45- # or
46-
47- await createBucketSnapshot ({
48- description: " pre-finetune" ,
49- config: {
50- bucket: " llm-base" ,
51- }
52- });
53- ```
54-
55- If you don't provide the bucket name in the ` config ` or ` sourceBucketName `
56- parameter, it will use the bucket name from either ` .env ` or environment
57- variables.
58-
59- ``` ts
60- import { createBucketSnapshot } from " @tigrisdata/storage" ;
61-
62- await createBucketSnapshot ({
47+ await createBucketSnapshot (" llm-base" , {
6348 description: " pre-finetune" ,
6449});
6550```
@@ -84,44 +69,66 @@ if (result.error) {
8469}
8570```
8671
87- If you don't provide the bucket name in the ` config ` or ` sourceBucketName `
88- parameter, it will use the bucket name from either ` .env ` or environment
89- variables .
72+ ## Create a fork from the bucket
73+
74+ Forks can be created using the ` createBucketFork ` function .
9075
9176``` ts
92- import { listBucketSnapshots } from " @tigrisdata/storage" ;
77+ import { createBucketFork } from " @tigrisdata/storage" ;
9378
94- const result = await listBucketSnapshots ();
95- ```
79+ const createFork = await createBucketFork (
80+ " llm-base-fork-4" , // forkname
81+ " llm-base" , // source bucket name
82+ );
9683
97- ## Create a fork from the bucket
84+ if (createFork .error ) {
85+ console .error (" error creating bucket fork" , createFork .error );
86+ } else {
87+ console .log (" bucket fork created" );
88+ }
89+ ```
9890
99- Forks can be created using the ` createBucketFork ` function.
91+ ## Create a fork from the bucket with a specific snapshot
10092
10193``` ts
10294import { createBucketFork } from " @tigrisdata/storage" ;
10395
104- await createBucketFork (" llm-base-fork" , " llm-base" );
96+ const forkName = " llm-fork" ;
97+ const sourceBucketName = " llm-base" ;
98+ const sourceBucketSnapshotName = " fine-tuned-model-345" ;
10599
106- # or
107-
108- await createBucketFork (" llm-base-fork" , {
109- config: {
110- bucket: " llm-base" ,
111- },
100+ const createFork = await createBucketFork (forkName , sourceBucketName , {
101+ sourceBucketSnapshot: sourceBucketSnapshotName ,
112102});
103+
104+ if (createFork .error ) {
105+ console .error (" error creating bucket fork" , createFork .error );
106+ } else {
107+ console .log (" bucket fork created" );
108+ }
113109```
114110
115- If you don't provide the bucket name in the ` config ` or ` sourceBucketName `
116- parameter, it will use the bucket name from either ` .env ` or environment
117- variables.
111+ :::note
118112
119- ## Create a fork from the bucket with a specific snapshot
113+ If you don't provide the bucket name in the ` sourceBucketName ` parameter, it
114+ will use the bucket name from either ` .env ` or environment variables.
115+
116+ :::
120117
121118``` ts
122- import { createBucketFork } from " @tigrisdata/storage" ;
119+ import {
120+ createBucketSnapshot ,
121+ createBucketFork ,
122+ listBucketSnapshots ,
123+ } from " @tigrisdata/storage" ;
124+
125+ await createBucketSnapshot ({
126+ description: " pre-finetune" ,
127+ });
128+
129+ await listBucketSnapshots ();
123130
124- await createBucketFork (" llm-base- fork" , " llm-base " , {
131+ await createBucketFork (" llm-fork" , {
125132 sourceBucketSnapshot: " fine-tuned-model-345" ,
126133});
127134```
0 commit comments