File size: 3,059 Bytes
1602ff5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# Define input data schema as a proper Python list (not a string)
input_schema = [
{
'id': '1',
'type': 'struct',
'fields': [
{
'name': 'cos_config',
'type': 'object',
'nullable': False,
'metadata': {
'description': 'Cloud Object Storage configuration'
}
},
{
'name': 'source_urls',
'type': 'array',
'nullable': False,
'metadata': {
'description': 'URLs of files to download and upload to COS'
}
},
{
'name': 'prefix',
'type': 'string',
'nullable': True,
'metadata': {
'description': 'Optional prefix to add to the file names in COS'
}
},
{
'name': 'http_method',
'type': 'string',
'nullable': True,
'metadata': {
'description': 'HTTP method to use for downloading files'
}
}
]
}
]
# Define output data schema as a proper Python list (not a string)
output_schema = [
{
'id': '1',
'type': 'struct',
'fields': [
{
'name': 'status',
'type': 'string',
'nullable': False,
'metadata': {
'description': 'Status of the operation (success or error)'
}
},
{
'name': 'data',
'type': 'object',
'nullable': True,
'metadata': {
'description': 'Response data containing upload details'
}
},
{
'name': 'message',
'type': 'string',
'nullable': True,
'metadata': {
'description': 'Error message if status is error'
}
}
]
}
]
# Define sample scoring input
sample_input = {
'input_data': [
{
'fields': ['cos_config', 'source_urls', 'prefix', 'http_method'],
'values': [
[
{
'bucket_name': 'my-bucket',
'api_key': '<your-cos-api-key>',
'instance_id': '<your-cos-instance-id>',
'auth_endpoint': 'https://iam.cloud.ibm.com/identity/token',
'endpoint_url': 'https://s3.eu-de.cloud-object-storage.appdomain.cloud'
},
[
'https://example.com/sample-file.pdf',
'https://example.com/another-file.csv'
],
'uploads/files',
'GET'
]
]
}
]
} |