Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

350
Views
¿Cómo abrir un archivo tar modelo almacenado en el cubo S3 en el cuaderno sagemaker?

Sé que cargar un archivo .csv en una notebook de Sagemaker desde el depósito S3 es bastante sencillo, pero quiero cargar un archivo model.tar.gz almacenado en el depósito S3. Traté de hacer lo siguiente

 import botocore import sagemaker from sagemaker import get_execution_role from sagemaker.predictor import csv_serializer import boto3 sm_client = boto3.client(service_name='sagemaker') runtime_sm_client = boto3.client(service_name='sagemaker-runtime') s3 = boto3.resource('s3') s3_client = boto3.client('s3') sagemaker_session = sagemaker.Session() role = get_execution_role() ACCOUNT_ID = boto3.client('sts').get_caller_identity()['Account'] REGION = boto3.Session().region_name BUCKET = 'sagemaker.prismade.net' data_key = 'DEMO_MME_ANN/multi_model_artifacts/axel.tar.gz' loc = 's3://{}/{}'.format(BUCKET, data_key) print(loc) with tarfile.open(loc) as tar: tar.extractall(path='.')

Obtuve el siguiente error:

 -------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-215-bfdddac71b95> in <module>() 20 loc = 's3://{}/{}'.format(BUCKET, data_key) 21 print(loc) ---> 22 with tarfile.open(loc) as tar: 23 tar.extractall(path='.') ~/anaconda3/envs/python3/lib/python3.6/tarfile.py in open(cls, name, mode, fileobj, bufsize, **kwargs) 1567 saved_pos = fileobj.tell() 1568 try: -> 1569 return func(name, "r", fileobj, **kwargs) 1570 except (ReadError, CompressionError): 1571 if fileobj is not None: ~/anaconda3/envs/python3/lib/python3.6/tarfile.py in gzopen(cls, name, mode, fileobj, compresslevel, **kwargs) 1632 1633 try: -> 1634 fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj) 1635 except OSError: 1636 if fileobj is not None and mode == 'r': ~/anaconda3/envs/python3/lib/python3.6/gzip.py in __init__(self, filename, mode, compresslevel, fileobj, mtime) 161 mode += 'b' 162 if fileobj is None: --> 163 fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') 164 if filename is None: 165 filename = getattr(fileobj, 'name', '') FileNotFoundError: [Errno 2] No such file or directory: 's3://sagemaker.prismade.net/DEMO_MME_ANN/multi_model_artifacts/axel.tar.gz'

¿Cuál es el error aquí y cómo puedo lograr esto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No todas las bibliotecas de Python que están diseñadas para funcionar con un sistema de archivos (tarfile.open, en este ejemplo) saben cómo leer un objeto de S3 como un archivo.

La forma sencilla de resolverlo es copiar primero el objeto en el sistema de archivos local como un archivo.

 import boto3 s3 = boto3.client('s3') s3.download_file('BUCKET_NAME', 'OBJECT_NAME', 'FILE_NAME')
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!