Skip to content

Commit

Permalink
Added multiple cycle upload argument (#27)
Browse files Browse the repository at this point in the history
* Added multiple cycle upload argument

* Responded to comments and fixed failing tests

* Converted to using kwargs

* Pre-commit
anchapin authored Nov 15, 2023
1 parent 82d7298 commit b3e2ba5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyseed/seed_client.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b3e2ba5

Please sign in to comment.