QWQyyy commented on issue #5427: URL: https://github.com/apache/openwhisk/issues/5427#issuecomment-1627289221
my code: ```python import pandas as pd from torchvision import datasets, transforms import numpy as np import os from minio import Minio from minio.error import S3Error def main(args): # 转换器 transform_train = transforms.Compose([transforms.RandomHorizontalFlip(p=0.5), transforms.ToTensor(), transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225))]) transform_test = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.485, 0.456, 0.406), (0.226, 0.224, 0.225))]) # 数据集路径 data_path = "/dataset/CIFAR10" # 加载训练集和测试集 train_dataset = datasets.CIFAR10(root=data_path, train=True, transform=transform_train, download=True) test_dataset = datasets.CIFAR10(root=data_path, train=False, transform=transform_test, download=True) # 将训练集数据保存到CSV文件 train_data = [] for i, (image, label) in enumerate(train_dataset): image_data = np.array(image).tolist() # 转换为列表 train_data.append([image_data, label]) train_df = pd.DataFrame(train_data, columns=['image', 'label']) train_csv_data = train_df.to_csv(index=False) save_to_minio(train_csv_data, "cifar", "train_dataset.csv") # 将测试集数据保存到CSV文件 test_data = [] for i, (image, label) in enumerate(test_dataset): image_data = np.array(image).tolist() # 转换为列表 test_data.append([image_data, label]) test_df = pd.DataFrame(test_data, columns=['image', 'label']) test_csv_data = test_df.to_csv(index=False) save_to_minio(test_csv_data, "cifar", "test_dataset.csv") result = {'res': '666'} return result def save_to_minio(data, bucket_name, object_name): # 创建与MinIO服务器的连接 client = Minio( "192.168.1.23:9000", access_key="CuZRDbhLVIIjfDp4M4p8", secret_key="tFDb4aoeSqlCB0bH6BoYfNvIWXqSCJQCZ6UD0Hd9", secure=False ) # 将数据保存到MinIO存储中 try: data_bytes = data.encode() # 将字符串转换为字节类型 data_stream = io.BytesIO(data_bytes) # 创建可读取的字节流 client.put_object(bucket_name, object_name, data_stream, len(data_bytes)) s1 = "echo 数据已成功保存到MinIO存储,存储桶:" + bucket_name + ",对象:" + object_name os.system(s1) except S3Error as exc: s2 = "echo 保存数据到MinIO存储失败:" + str(exc) os.system(s2) ``` Is it because I called the external storage during the execution of the openwhisk function, so the function cannot be executed smoothly? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@openwhisk.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org