Skip to content

Commit 5054112

Browse files
author
Lingling Peng
committed
turn schema to required; fix delete_none_key
1 parent 0f9c9e2 commit 5054112

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

synapseclient/models/curation.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,15 +1008,15 @@ class GridCsvImportRequest(AsynchronousCommunicator):
10081008
file_handle_id: str
10091009
"""The id of the file handle that contains the CSV data."""
10101010

1011+
schema: list[Column]
1012+
"""The list of ColumnModel that describe the CSV file. Currently this is required."""
1013+
10111014
concrete_type: str = GRID_CSV_IMPORT_REQUEST
10121015
"""The concrete type for this request."""
10131016

10141017
csv_descriptor: CsvTableDescriptor = field(default_factory=CsvTableDescriptor)
10151018
"""The description of a csv for upload or download."""
10161019

1017-
schema: Optional[List[Column]] = None
1018-
"""The list of ColumnModel that describe the CSV file. Currently this is required."""
1019-
10201020
# Response fields (populated by fill_from_dict)
10211021
total_count: Optional[int] = field(default=None, compare=False)
10221022
"""The total number of rows in the CSV."""
@@ -1089,7 +1089,7 @@ class UploadToTablePreviewRequest(AsynchronousCommunicator):
10891089
csv_table_descriptor: CsvTableDescriptor = field(default_factory=CsvTableDescriptor)
10901090
"""The description of a csv for upload or download."""
10911091

1092-
do_full_file_scan: Optional[bool] = None
1092+
do_full_file_scan: Optional[bool] = False
10931093
"""When set to true the full file will be scanned for a schema suggestions. A full scan is more accurate but can take more time. When set to false only a sub-set of the first rows will be scanned, which can be faster but is less accurate. The default value is false."""
10941094

10951095
# Response fields (populated by fill_from_dict)
@@ -1140,9 +1140,12 @@ def to_synapse_request(self) -> Dict[str, Any]:
11401140
"concreteType": self.concrete_type,
11411141
"uploadFileHandleId": self.upload_file_handle_id,
11421142
"linesToSkip": self.lines_to_skip,
1143-
"csvTableDescriptor": self.csv_table_descriptor.to_synapse_request(),
11441143
"doFullFileScan": self.do_full_file_scan,
11451144
}
1145+
if self.csv_table_descriptor is not None:
1146+
request_dict["csvTableDescriptor"] = (
1147+
self.csv_table_descriptor.to_synapse_request()
1148+
)
11461149
delete_none_keys(request_dict)
11471150
return request_dict
11481151

tests/unit/synapseclient/models/async/unit_test_curation_async.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ async def test_import_csv_async(self) -> None:
859859
mock_import_response = GridCsvImportRequest(
860860
session_id=SESSION_ID,
861861
file_handle_id=FILE_HANDLE_ID,
862+
schema=expected_columns,
862863
total_count=1,
863864
created_count=1,
864865
updated_count=1,
@@ -1055,7 +1056,9 @@ def test_fill_from_dict(self) -> None:
10551056

10561057
# WHEN I fill a GridCsvImportRequest from the response
10571058
import_req = GridCsvImportRequest(
1058-
session_id=SESSION_ID, file_handle_id=FILE_HANDLE_ID
1059+
session_id=SESSION_ID,
1060+
file_handle_id=FILE_HANDLE_ID,
1061+
schema=[Column(name="col1", column_type="STRING")],
10591062
)
10601063
result = import_req.fill_from_dict(raw_synapse_response)
10611064

0 commit comments

Comments
 (0)