I’m trying to upload a PyTorch scaler to S3 so that I can access it individually without having to download the model bundle. Doing some research I thought I would be able to upload it anywhere else other than the ‘/opt/ml/model’ and it wouldn’t be bundled. Below is the python code I’m using to try to upload it. This code still seems to bundle the scaler with the model.
# Save the scaler with a timestamp
scaler_output_path = os.path.join('/opt/ml/output', f'scaler_{timestamp}.pkl')
joblib.dump(scaler, scaler_output_path)
print(f"Scaler saved to {scaler_output_path}")
# Upload the scaler and timestamp to S3
s3_client = boto3.client('s3')
# Upload scaler
try:
s3_client.upload_file(scaler_output_path, bucket_name, f'{s3_prefix}scaler_{timestamp}.pkl')
print(f"Scaler uploaded to s3://{bucket_name}/{s3_prefix}scaler_{timestamp}.pkl")
except Exception as e:
print(f"Failed to upload scaler: {e}")