26
26
def get_deployments (user , pwd ):
27
27
"""
28
28
Fetches deployments from the specified URL using the provided username and password for authentication.
29
-
30
- Args:
31
- username (str): The username for authentication.
32
- password (str): The password for authentication.
33
-
34
- Returns:
35
- list: A list of deployments if the request is successful, otherwise an empty list.
36
29
"""
37
30
try :
38
31
url = "https://connect-apps.ceh.ac.uk/ami-data-upload/get-deployments/"
@@ -54,18 +47,6 @@ async def get_presigned_url(
54
47
):
55
48
"""
56
49
Fetches a presigned URL for uploading a file using the provided details.
57
-
58
- Args:
59
- username (str): The username for authentication.
60
- password (str): The password for authentication.
61
- name (str): The name associated with the upload.
62
- bucket (str): The S3 bucket name.
63
- dep_id (str): The deployment ID.
64
- data_type (str): The type of data being uploaded.
65
- file_name (str): The name of the file to be uploaded.
66
-
67
- Returns:
68
- dict: The JSON response containing the presigned URL if the request is successful.
69
50
"""
70
51
url = "https://connect-apps.ceh.ac.uk/ami-data-upload/generate-presigned-url/"
71
52
@@ -86,14 +67,6 @@ async def get_presigned_url(
86
67
async def upload_file_to_s3 (session , presigned_url , file_content , file_type ):
87
68
"""
88
69
Uploads a file to S3 using a presigned URL.
89
-
90
- Args:
91
- presigned_url (str): The presigned URL for uploading the file.
92
- file_content (bytes): The content of the file to be uploaded.
93
- file_type (str): The MIME type of the file.
94
-
95
- Returns:
96
- None
97
70
"""
98
71
headers = {"Content-Type" : file_type }
99
72
async with session .put (
@@ -107,19 +80,6 @@ async def upload_files_in_batches(
107
80
):
108
81
"""
109
82
Uploads files in batches to S3.
110
-
111
- Args:
112
- username (str): The username for authentication.
113
- password (str): The password for authentication.
114
- name (str): The name associated with the upload.
115
- bucket (str): The S3 bucket name.
116
- dep_id (str): The deployment ID.
117
- data_type (str): The type of data being uploaded.
118
- files (list): A list of tuples containing file name, file content, and file type.
119
- batch_size (int, optional): The number of files to upload in each batch. Defaults to 50.
120
-
121
- Returns:
122
- None
123
83
"""
124
84
async with aiohttp .ClientSession (timeout = ClientTimeout (total = 1200 )) as session :
125
85
while True :
@@ -150,17 +110,6 @@ async def upload_files(session, user, pwd, name, bucket, dep_id, data_type, file
150
110
"""
151
111
Uploads multiple files to S3 by first obtaining presigned URLs and then uploading the files.
152
112
153
- Args:
154
- username (str): The username for authentication.
155
- password (str): The password for authentication.
156
- name (str): The name associated with the upload.
157
- bucket (str): The S3 bucket name.
158
- dep_id (str): The deployment ID.
159
- data_type (str): The type of data being uploaded.
160
- files (list): A list of tuples containing file name, file content, and file type.
161
-
162
- Returns:
163
- None
164
113
"""
165
114
tasks = []
166
115
for file_name , file_content , file_type in files :
@@ -225,14 +174,6 @@ def get_file_info(file_path):
225
174
def main (user , pwd , deployments ):
226
175
"""
227
176
The main function to handle the user interface and interaction in the Streamlit app.
228
-
229
- Args:
230
- username (str): The username for authentication.
231
- password (str): The password for authentication.
232
- deployments (list): A list of deployments fetched from the server.
233
-
234
- Returns:
235
- None
236
177
"""
237
178
if not deployments :
238
179
st .error (
@@ -318,19 +259,6 @@ def handle_upload(
318
259
):
319
260
"""
320
261
Handles the file upload process by validating inputs and initiating the upload.
321
-
322
- Args:
323
- username (str): The username for authentication.
324
- password (str): The password for authentication.
325
- full_name (str): The full name of the user.
326
- country (str): The selected country.
327
- deployment (str): The selected deployment.
328
- data_type (str): The type of data being uploaded.
329
- uploaded_files (list): A list of uploaded files.
330
- deployments (list): A list of deployments fetched from the server.
331
-
332
- Returns:
333
- None
334
262
"""
335
263
if not full_name :
336
264
st .warning ("Please enter your full name." )
0 commit comments