File tree Expand file tree Collapse file tree 1 file changed +20
-18
lines changed
libs/labelbox/src/labelbox/schema Expand file tree Collapse file tree 1 file changed +20
-18
lines changed Original file line number Diff line number Diff line change @@ -107,11 +107,14 @@ def upload_members(
107
107
# Reset pointer to start of stream
108
108
buffer .seek (0 )
109
109
110
- multipart_file_field = "1"
110
+ # Use 0-based indexing as per common convention
111
+ multipart_file_field = "0"
111
112
gql_file_field = "file"
113
+
114
+ # Prepare the file content
112
115
files = {
113
116
multipart_file_field : (
114
- f" { multipart_file_field } .csv" ,
117
+ "members .csv" , # More descriptive filename
115
118
buffer ,
116
119
"text/csv" ,
117
120
)
@@ -128,25 +131,24 @@ def upload_members(
128
131
}
129
132
}
130
133
"""
131
- params = {
132
- "roleId" : role_id ,
133
- gql_file_field : None ,
134
- "where" : {"id" : group_id },
134
+ # Construct the multipart request following the spec
135
+ operations = {
136
+ "query" : query ,
137
+ "variables" : {
138
+ "roleId" : role_id ,
139
+ gql_file_field : None , # Placeholder for file
140
+ "where" : {"id" : group_id },
141
+ },
135
142
}
136
143
144
+ # Map file to the variable
145
+ map_data = {multipart_file_field : [f"variables.{ gql_file_field } " ]}
146
+
137
147
request_data = {
138
- "operations" : json .dumps (
139
- {
140
- "variables" : params ,
141
- "query" : query ,
142
- }
143
- ),
144
- "map" : (
145
- None ,
146
- json .dumps (
147
- {multipart_file_field : [f"variables.{ gql_file_field } " ]}
148
- ),
149
- ),
148
+ "operations" : json .dumps (operations ),
149
+ "map" : json .dumps (
150
+ map_data
151
+ ), # Remove the unnecessary (None, ...) tuple
150
152
}
151
153
152
154
client = self .client
You can’t perform that action at this time.
0 commit comments