Docsity

computer science kubernetes ai, Schemes and Mind Maps of Computer Applications

Toggle sidebar
bg1
Red Hat OpenShift AI Self-Managed
2.25
Working with data in an S3-compatible object
store
Work with data stored in an S3-compatible object store from your workbench
Last Updated: 2025-10-28
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download computer science kubernetes ai and more Schemes and Mind Maps Computer Applications in PDF only on Docsity!

Red Hat OpenShift AI Self-Managed

Working with data in an S3-compatible object

store

Work with data stored in an S3-compatible object store from your workbench

Last Updated: 2025-10-

Legal Notice

Copyright © 2025 Red Hat, Inc.

The text of and illustrations in this document are licensed by Red Hat under a Creative Commons

Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is

available at

http://creativecommons.org/licenses/by-sa/3.0/

. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must

provide the URL for the original version.

Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,

Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.

Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift,

Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States

and other countries.

Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.

Java ® is a registered trademark of Oracle and/or its affiliates.

XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States

and/or other countries.

MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and

other countries.

Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the

official Joyent Node.js open source or commercial project.

The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks

or trademarks/service marks of the OpenStack Foundation, in the United States and other

countries and are used with the OpenStack Foundation's permission. We are not affiliated with,

endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.

All other trademarks are the property of their respective owners.

Abstract

Learn how to work with data stored in an S3-compatible object store from your workbench.

.......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... .......................................................................................................................... ..........................................................................................................................

Table of Contents

PREFACE CHAPTER 1. PREREQUISITES CHAPTER 2. CREATING AN S3 CLIENT CHAPTER 3. LISTING AVAILABLE BUCKETS IN YOUR OBJECT STORE CHAPTER 4. CREATING A BUCKET IN YOUR OBJECT STORE CHAPTER 5. LISTING FILES IN YOUR BUCKET CHAPTER 6. DOWNLOADING FILES FROM YOUR BUCKET CHAPTER 7. UPLOADING FILES TO YOUR BUCKET CHAPTER 8. COPYING FILES BETWEEN BUCKETS CHAPTER 9. DELETING FILES FROM YOUR BUCKET CHAPTER 10. DELETING A BUCKET FROM YOUR OBJECT STORE CHAPTER 11. OVERVIEW OF OBJECT STORAGE ENDPOINTS 11.1. MINIO (ON-CLUSTER) 11.2. AMAZON S 11.3. OTHER S3-COMPATIBLE OBJECT STORES 11.4. VERIFICATION AND TROUBLESHOOTING CHAPTER 12. ACCESSING S3-COMPATIBLE OBJECT STORAGE WITH SELF-SIGNED CERTIFICATES CHAPTER 13. ADDITIONAL RESOURCES 3 4 5 8 9 10 12 13 14 16 17 18 18 18 19 19 20 22 Table of Contents

PREFACE If you have data stored in an S3-compatible object store such as Ceph, MinIO, or IBM Cloud Object Storage, you can access the data from your workbench. PREFACE

CHAPTER 1. PREREQUISITES You have created a workbench in OpenShift AI. For more information, see Creating a workbench and selecting an IDE. You have access to an S3-compatible object store. You have the credentials for your S3-compatible object storage account. You have files to work with in your object store. You have configured a connection for your workbench based on the credentials of your S3- compatible storage account. For more information, see Using connections. Red Hat OpenShift AI Self-Managed 2.25 Working with data in an S3-compatible object store

Installing Boto3 and required Boto3 libraries Creating an S3 client session Creating an S3 client connection Listing files Creating a bucket Uploading a file to a bucket Downloading a file from a bucket Copying files between buckets Deleting an object from a bucket Deleting a bucket

  1. In the Jupyter notebook, locate the following instructions to install Boto3 and its required libraries, and run the code cell: #Upgrade pip to the latest version !pip3 install --upgrade pip #Install Boto !pip3 install boto #Install Boto3 libraries import os import boto from botocore.client import Config from boto3 import session #Check Boto3 version !pip3 show boto The instructions in the code cell update the Python Package Manager (pip) to the latest version, install Boto3 and its required libraries, and display the version of Boto3 installed.
  2. Locate the following instructions to create an S3 client and session. Run the code cell. #Creating an S3 client #Define credentials key_id = os.environ.get('AWS_ACCESS_KEY_ID') secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY') endpoint = os.environ.get('AWS_S3_ENDPOINT') region = os.environ.get('AWS_DEFAULT_REGION') #Define client session session = Boto3.session.Session(aws_access_key_id=key_id, aws_secret_access_key=secret_key) #Define client connection s3_client = Boto3.client('s3', aws_access_key_id=key_id, aws_secret_access_key=secret_key,aws_session_token=None, Red Hat OpenShift AI Self-Managed 2.25 Working with data in an S3-compatible object store

config=Boto3.session.Config(signature_version='s3v4'), endpoint_url=endpoint, region_name=region) The instructions in the code cell configure an S3 client and establish a session to your S3- compatible object store. Verification To use the S3 client to connect to your object store and list the available buckets, locate the following instructions to list buckets and run the code cell: s3_client.list_buckets() A successful response includes a HTTPStatusCode of 200 and a list of buckets similar to the following output: 'HTTPStatusCode': 200, 'Buckets': [{'Name': 'aqs086-image-registry', 'CreationDate': datetime.datetime(2024, 1, 16, 20, 21, 36, 244000, tzinfo=tzlocal ())}] CHAPTER 2. CREATING AN S3 CLIENT

CHAPTER 4. CREATING A BUCKET IN YOUR OBJECT STORE To create a bucket in your object store from your workbench, use the create_bucket() method. Prerequisites You have cloned the odh-doc-examples repository to your workbench. You have opened the s3client_examples.ipynb file in your workbench. You have installed Boto3 and configured an S3 client. Procedure

  1. In the notebook file, locate the following instructions to create a bucket: #Create bucket ` s3_client.create_bucket(Bucket='<bucket_name>')
  2. Replace <name_of_the_bucket> with the name of the bucket that you want to create, as shown in the example, and then run the code cell. #Create bucket s3_client.create_bucket(Bucket='aqs43-image-registry') The output displays an HTTP response status code of 200 , indicating a successful request. Verification Locate the instructions to list buckets and execute the code cell. for bucket in s3_client.list_bucket()[‘Buckets’]: print(bucket[‘Name’]) The bucket that you created is displayed in the output. CHAPTER 4. CREATING A BUCKET IN YOUR OBJECT STORE

CHAPTER 5. LISTING FILES IN YOUR BUCKET To list files in a specific bucket, use the list_bucket_v2() method. Prerequisites You have cloned the odh-doc-examples repository to your workbench. You have opened the s3client_examples.ipynb file in your workbench. You have installed Boto3 and configured an S3 client. Procedure

  1. In the Jupyter notebook, locate the following code for listing files. #List files #Replace <bucket_name> with the name of the bucket. bucket_name = ‘<bucket_name>’ s3_client.list_objects_v2(Bucket=bucket_name)
  2. Replace <bucket_name> with the name of your own bucket, as shown in the example, and then run the code cell. #List files #Replace <bucket_name> with the name of the bucket. bucket_name = ‘aqs27-registry’ s3_client.list_objects_v2(Bucket=bucket_name) The output displays information about the files that are available in the specified bucket.
  3. Locate the code cell that lists only the names of the files. #Print only names of files bucket_name = ‘<bucket_name>’ for key in s3_client.list_objects_v2(Bucket=bucket_name)[‘Contents’]: print(key[‘Key’])
  4. Replace <bucket_name> with the name of your bucket, as shown in the example, and run the code cell: #Print only names of files bucket_name = ‘aqs27-registry’ for key in s3_client.list_objects_v2(Bucket=bucket_name)[‘Contents’]: print(key[‘Key’]) The output displays a list of file names that are available in the specified bucket.
  5. Refine the previous query to specify a file path, by locating the following code cell: bucket_name = ‘<bucket_name>’ for key in s3_client.list_objects_v2(Bucket=bucket_name,Prefix=’<start_of_file_path’) [‘Contents’]: print(key[‘Key’]) Red Hat OpenShift AI Self-Managed 2.25 Working with data in an S3-compatible object store

CHAPTER 6. DOWNLOADING FILES FROM YOUR BUCKET To download a file from your bucket to your workbench, use the download_file() method. Prerequisites You have cloned the odh-doc-examples repository to your workbench. You have opened the s3client_examples.ipynb file in your workbench. You have installed Boto3 and configured an S3 client. Procedure

  1. In the Jupyter notebook, locate the following instructions to download files from a bucket: #Download file from bucket #Replace the following values with your own: #<bucket_name>: The name of the bucket. #<object_name>: The name of the file to download. Must include full path to the file on the bucket. #<file_name>: The name of the file when downloaded. s3_client.download_file('<bucket_name>','<object_name>','<file_name>')
  2. Modify the code sample: a. Replace <bucket_name> with the name of the bucket that the file is located in… Replace <object_name> with the name of the file that you want to download. b. Replace <file_name> with the name and path that you want the file to be downloaded to, as shown in the example. s3_client.download_file('aqs086-image-registry', 'series35-image36-086.csv', '\tmp\series35-image36-086.csv_old')
  3. Run the code cell. Verification The file that you downloaded is displayed in the path that you specified on your workbench. Red Hat OpenShift AI Self-Managed 2.25 Working with data in an S3-compatible object store

CHAPTER 7. UPLOADING FILES TO YOUR BUCKET To upload files to your bucket from your workbench, use the upload_file() method. Prerequisites You have cloned the odh-doc-examples repository to your workbench. You have opened the s3client_examples.ipynb file in your workbench. You have installed Boto3 and configured an S3 client. You have imported the files that you want to upload to your object store to your workbench. Procedure

  1. In the Jupyter notebook, locate the instructions to upload files to a bucket. #Upload file to bucket #Replace <file_name>, <bucket_name>, and <object_name> with your values. #<file_name>: Name of the file to upload. This value must include the full local path to the file on your workbench. #<bucket_name>: The name of the bucket to upload the file to. #<object_name>: The full key to use to save the file to the bucket. s3_client.upload_file('<file_name>', '<bucket_name>', '<object_name>')
  2. Replace <file_name> , <bucket_name> and <object_name> with your own values, as shown in the example, and then run the code cell. s3_client.upload_file('image-973-series123.csv', 'aqs973-image-registry', '/tmp/image-973- series124.csv') Verification Locate the following instructions to list files in a bucket: #Upload Verification for key in s3_client.list_objects_v2(Bucket='<bucket_name>')['Contents']: print(key['Key']) Replace <bucket_name> with the name of your bucket, as shown in the example, and then run the code cell. #Upload Verification for key in s3_client.list_objects_v2(Bucket='aqs973-image-registry')['Contents']: print(key['Key']) The file that you uploaded is displayed in the output. CHAPTER 7. UPLOADING FILES TO YOUR BUCKET

#Copy Verification bucket_name = 'aqs971-image-registry' for key in s3_client.list_objects_v2(Bucket=bucket_name)['Contents']: print(key['Key']). The file that you copied is displayed in the output. CHAPTER 8. COPYING FILES BETWEEN BUCKETS

CHAPTER 9. DELETING FILES FROM YOUR BUCKET To delete files from your bucket from your workbench, use the delete_file() method. Prerequisites You have cloned the odh-doc-examples repository to your workbench. You have opened the s3client_examples.ipynb file in your workbench. You have installed Boto3 and configured an S3 client. You know the key of the file you want to delete and the bucket that the file is located in. Procedure

  1. In the Jupyter notebook, locate the following instructions to delete files from a bucket: #Delete files from bucket s3_client.delete_object(Bucket='<bucket_name>', Key='<object_key>')
  2. Replace <bucket_name> with the name of your bucket and with the key of the file you want to delete, as shown in the example. Run the code cell. #Delete object from bucket s3_client.delete_object(Bucket='aqs971-image-registry', Key='/tmp/series43-image12- 086.csv') The output displays a HTTP response status code of 204 , which indicates that the request was successful. Verification Locate the following instructions to list files in a bucket: #Delete Object Verification bucket_name = '<bucket_name>' for key in s3_client.list_objects_v2(Bucket=bucket_name)['Contents']: print(key['Key']) Replace <bucket_name> with the name of your bucket, as shown in the example and run the code cell. #Delete Object Verification bucket_name = 'aqs971-image-registry' for key in s3_client.list_objects_v2(Bucket=bucket_name)['Contents']: print(key['Key']) The deleted file does not appear in the output. Red Hat OpenShift AI Self-Managed 2.25 Working with data in an S3-compatible object store