-
Notifications
You must be signed in to change notification settings - Fork 10
Update boto3 code example in fork buckets blog post #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,50 @@ own copy of the data. Let's walk through the pattern using Tigris: | |
| start_agent(agent_bucket_name) | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="boto3" label="Python (boto3)"> | ||
| ```python | ||
| # In your terminal, install the boto3 extension | ||
| pip install tigris-boto3-ext | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be outside the python code block into its own
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's intentionally in the tabbed view so it is alongside the other code examples. I added a "In your terminal, install..." so it's more clear.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code is not quickly copy-pastable then. Because copying it using the shortcut will end up copying the |
||
|
|
||
| # Now, the code | ||
| import boto3 | ||
| from tigris_boto3_ext import ( | ||
| TigrisSnapshotEnabled, | ||
| create_snapshot_bucket, | ||
| create_snapshot, | ||
| get_snapshot_version, | ||
| create_fork, | ||
| ) | ||
|
|
||
| # Initialize boto3 S3 client for Tigris | ||
| s3_client = boto3.client( | ||
| 's3', | ||
| endpoint_url='https://t3.storage.tigris.dev', | ||
| aws_access_key_id='your-access-key', | ||
| aws_secret_access_key='your-secret-key', | ||
| ) | ||
|
|
||
| # Create a seed bucket | ||
| seed_bucket_name = 'agent-seed' | ||
| create_snapshot_bucket(s3, seed_bucket_name) | ||
|
|
||
| # Create snapshot | ||
| result = create_snapshot(s3_client, seed_bucket_name, snapshot_name='agent-seed-v1') | ||
| snapshot_version = get_snapshot_version(result) | ||
|
|
||
| # Fork the bucket from the snapshot for a new agent | ||
| agent_bucket_name = f"{seed_bucket_name}-agent-{agent_id}"; | ||
| create_fork(s3_client, agent_bucket_name, seed_bucket_name, snapshot_version=snapshot_version) | ||
|
|
||
| # Start the agent using the forked bucket | ||
| start_agent(agent_bucket_name) | ||
|
|
||
| # Standard boto3 operations work normally: | ||
| s3_client.put_object(Bucket=seed_bucket_name, Key='config.json', Body=b'{}') | ||
| s3_client.put_object(Bucket=seed_bucket_name, Key='data.txt', Body=b'seed data') | ||
| ``` | ||
|
|
||
| </TabItem> | ||
| <TabItem value="javascript" label="JavaScript"> | ||
| ```javascript | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the
pythontab with this one?