Skip to content

Commit

Permalink
Fixed pre-existing ProgressData bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
axelstudios committed Dec 13, 2024
1 parent 30ac118 commit 2722c8d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions seed/data_importer/tests/test_ah_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def setUp(self):
"data_state": DATA_STATE_MAPPING,
}

progress_data = ProgressData(func_name="match_buildings", unique_id=self.import_file)
sub_progress_data = ProgressData(func_name="match_sub_progress", unique_id=self.import_file)
progress_data = ProgressData(func_name="match_buildings", unique_id=self.import_file.id)
sub_progress_data = ProgressData(func_name="match_sub_progress", unique_id=self.import_file.id)
self.action_args = [self.import_file.id, progress_data.key, sub_progress_data.key]

self.blank_result = {
Expand Down
26 changes: 14 additions & 12 deletions seed/lib/progress_data/progress_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import logging
from typing import Union

from seed.decorators import get_prog_key
from seed.utils.cache import delete_cache, get_cache, set_cache
Expand All @@ -12,11 +13,11 @@


class ProgressData:
def __init__(self, func_name, unique_id, init_data=None):
def __init__(self, func_name, unique_id: Union[str, int], init_data=None):
self.func_name = func_name
self.unique_id = unique_id
self.key = get_prog_key(func_name, unique_id)
self.total = None
self.total: Union[int, None] = None
self.increment_by = None

# Load in the initialized data, some of this may be overloaded based
Expand All @@ -30,16 +31,17 @@ def initialize(self, init_data=None):
if init_data:
self.data = init_data
else:
self.data = {}
self.data["status"] = "not-started"
self.data["status_message"] = ""
self.data["progress"] = 0
self.data["progress_key"] = self.key
self.data["unique_id"] = self.unique_id
self.data["func_name"] = self.func_name
self.data["message"] = None
self.data["stacktrace"] = None
self.data["summary"] = None
self.data = {
"status": "not-started",
"status_message": "",
"progress": 0,
"progress_key": self.key,
"unique_id": self.unique_id,
"func_name": self.func_name,
"message": None,
"stacktrace": None,
"summary": None,
}
self.total = None
self.increment_by = None

Expand Down
4 changes: 2 additions & 2 deletions seed/tests/test_derived_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ def setUp(self):
"import_file_id": self.import_file.id,
"data_state": DATA_STATE_MAPPING,
}
progress_data = ProgressData(func_name="match_buildings", unique_id=self.import_file)
sub_progress_data = ProgressData(func_name="match_sub_progress", unique_id=self.import_file)
progress_data = ProgressData(func_name="match_buildings", unique_id=self.import_file.id)
sub_progress_data = ProgressData(func_name="match_sub_progress", unique_id=self.import_file.id)
self.action_args = [self.import_file.id, progress_data.key, sub_progress_data.key]

# set up factory
Expand Down

0 comments on commit 2722c8d

Please sign in to comment.