forked from MagaluCloud/s3-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* disable poetry package mode * improve README * add papermill * add boto3 * add post-install script to create a poetry env for jupyter * remove placeholder spec * boto3 list-buckets example * improve docs
- Loading branch information
Showing
7 changed files
with
913 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Glossary | ||
|
||
<span id="profile">profile</span>: A profile is a set of configs, such as region and endpoint, and credentials, such as api_key_id and api_secret_key. On aws cli and sdks, the profile have a name and the data lives on user config directories like `~/.aws/config` and `~/.aws/credentials`. Those tools may accept an environment variable `AWS_PROFILE` or an argument `--profile` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4766f865-3d49-40ff-a12d-633d687203e6", | ||
"metadata": {}, | ||
"source": [ | ||
"# List buckets\n", | ||
"List all buckets from a profile[<sup>1</sup>](./glossary#profile)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "bad9760b-0b1b-46d1-b193-c9d5d433fd9d", | ||
"metadata": { | ||
"editable": true, | ||
"jp-MarkdownHeadingCollapsed": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"## Setup" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "908caaf7-3fe6-42de-a1fb-fafdc7732383", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [ | ||
"parameters" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Parameters\n", | ||
"profile_name = \"default\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "0d2cecec-ab01-46b6-a608-4e8f9e297ebb", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"execution started at 2024-10-24 23:27:45.201904\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import datetime\n", | ||
"print(f'execution started at {datetime.datetime.now()}')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fe6d5256-8f0f-4f00-988d-6f9845b51a69", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Client instantiation\n", | ||
"import boto3\n", | ||
"session = boto3.Session(profile_name=profile_name)\n", | ||
"s3_client = session.client('s3')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "599ec07a-a806-4ee4-ac7c-07137ad6be74", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [] | ||
}, | ||
"source": [ | ||
"## Example" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7fa5c156-2f2c-41a6-84c0-e4ec6a628ce6", | ||
"metadata": { | ||
"editable": true, | ||
"slideshow": { | ||
"slide_type": "" | ||
}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"response = s3_client.list_buckets()\n", | ||
"buckets = response.get('Buckets')\n", | ||
"print(f\"Profile '{profile_name}' has {len(buckets)} buckets.\")\n", | ||
"\n", | ||
"import random\n", | ||
"print(f\"One of those buckets is named {random.choice(buckets).get('Name')}\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "edb44a40-de96-472f-b8b8-a6596f7f1aa2", | ||
"metadata": {}, | ||
"source": [ | ||
"## References\n", | ||
"\n", | ||
"- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/list_buckets.html\n", | ||
" " | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python (Poetry)", | ||
"language": "python", | ||
"name": "my-poetry-env" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.