From b3e2ba5beb95f6c9dc5a13756513197685b4fd20 Mon Sep 17 00:00:00 2001 From: Alex Chapin Date: Wed, 15 Nov 2023 17:57:13 +0000 Subject: [PATCH] Added multiple cycle upload argument (#27) * Added multiple cycle upload argument * Responded to comments and fixed failing tests * Converted to using kwargs * Pre-commit --- pyseed/seed_client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyseed/seed_client.py b/pyseed/seed_client.py index c60335b..1309794 100644 --- a/pyseed/seed_client.py +++ b/pyseed/seed_client.py @@ -1154,12 +1154,13 @@ def get_meter_data(self, property_id, interval: str = 'Exact', excluded_meter_id def save_meter_data(self, property_id: int, meter_id: int, meter_data) -> dict: pass - def start_save_data(self, import_file_id: int) -> dict: + def start_save_data(self, import_file_id: int, multiple_cycle_upload: bool = False) -> dict: """start the background process to save the data file to the database. This is the state before the mapping. Args: import_file_id (int): id of the import file to save + multiple_cycle_upload (bool): whether to use multiple cycle upload Returns: dict: progress key @@ -1172,7 +1173,8 @@ def start_save_data(self, import_file_id: int) -> dict: return self.client.post( "import_files_start_save_data_pk", url_args={"PK": import_file_id}, - json={"cycle_id": self.cycle_id}, + json={"cycle_id": self.cycle_id, + "multiple_cycle_upload": multiple_cycle_upload}, ) def start_map_data(self, import_file_id: int) -> dict: @@ -1321,6 +1323,7 @@ def upload_and_match_datafile( column_mapping_profile_name (str): Name of the column mapping profile to use column_mappings_file (str): Mapping that will be uploaded to the column_mapping_profile_name import_meters_if_exist (bool): If true, will import meters from the meter tab if they exist in the datafile. Defaults to False. + multiple_cycle_upload (bool): Whether to use multiple cycle upload. Defaults to False. Returns: dict: { @@ -1331,9 +1334,10 @@ def upload_and_match_datafile( dataset = self.get_or_create_dataset(dataset_name) result = self.upload_datafile(dataset["id"], datafile, datafile_type) import_file_id = result["import_file_id"] + multiple_cycle_upload = kwargs.pop("multiple_cycle_upload", False) # start processing - result = self.start_save_data(import_file_id) + result = self.start_save_data(import_file_id, multiple_cycle_upload) progress_key = result.get("progress_key", None) # wait until upload is complete