Skip to content

Commit

Permalink
update again
Browse files Browse the repository at this point in the history
  • Loading branch information
tunglxfast committed Dec 16, 2024
1 parent 5784ac2 commit 192a796
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion datamimic_ce/clients/database_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_by_page_with_type(self, table_name: str, pagination: DataSourcePaginatio

@abstractmethod
def get_cyclic_data(
self, query: str, data_len: int, pagination: DataSourcePagination | None, cyclic: bool | None = False
self, query: str, data_len: int, pagination: DataSourcePagination, cyclic: bool = False
) -> list:
"""
Get cyclic data from database
Expand Down
2 changes: 1 addition & 1 deletion datamimic_ce/clients/rdbms_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class RdbmsClient(DatabaseClient):
def __init__(self, credential: RdbmsCredential, task_id: Optional[str] = None):
def __init__(self, credential: RdbmsCredential, task_id: str | None = None):
self._credential = credential
self._engine = None
self._task_id = task_id
Expand Down
2 changes: 1 addition & 1 deletion datamimic_ce/converter/converter_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class ConverterUtil:
@staticmethod
def get_hash_value(hash_type: str, output_format: str, value: str, salt: Optional[str] = None) -> str:
def get_hash_value(hash_type: str, output_format: str, value: str, salt: str | None = None) -> str:
hash_module_name = hash_type
try:
hash_module = importlib.import_module("hashlib").__getattribute__(hash_module_name)
Expand Down
2 changes: 1 addition & 1 deletion datamimic_ce/converter/hash_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HashConverter(Converter):
Optionally, can enhance the hash with salt
"""

def __init__(self, hash_type: str, output_format: str, salt: Optional[str] = None):
def __init__(self, hash_type: str, output_format: str, salt: str | None = None):
support_hashes = set(support_hash.value for support_hash in SupportHash)
support_output_format = set(support_output.value for support_output in SupportOutputFormat)
if hash_type.lower() not in support_hashes:
Expand Down
4 changes: 2 additions & 2 deletions datamimic_ce/credentials/mongodb_credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class MongoDBCredential(BaseModel, Credential):
host: str
port: int
database: str
user: Optional[str] = None
password: Optional[str] = None
user: str | None = None
password: str | None = None

model_config = ConfigDict(extra="allow")

Expand Down
3 changes: 1 addition & 2 deletions datamimic_ce/data_sources/weighted_entity_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import random
from pathlib import Path
from typing import Optional

from datamimic_ce.generators.generator import Generator
from datamimic_ce.utils.file_content_storage import FileContentStorage
Expand Down Expand Up @@ -43,7 +42,7 @@ class WeightedEntityDataSource(Generator):
file_path (str): file path of "entity.wgt.ent.csv", check Example for format detail of this file type
"""

def __init__(self, file_path: Path, separator: str, weight_column_name: Optional[str] = None):
def __init__(self, file_path: Path, separator: str, weight_column_name: str | None = None):
file_store = FileContentStorage()
weight_column = weight_column_name or "weight"
self._weights, self._data_dict_list = file_store.load_file_with_custom_func(
Expand Down
9 changes: 4 additions & 5 deletions datamimic_ce/datamimic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import traceback
import uuid
from pathlib import Path
from typing import Optional

from datamimic_ce.config import settings
from datamimic_ce.exporters.test_result_exporter import TestResultExporter
Expand All @@ -27,11 +26,11 @@ class DataMimic:
def __init__(
self,
descriptor_path: Path,
task_id: Optional[str] = None,
platform_props: Optional[dict[str, str]] = None,
platform_configs: Optional[dict] = None,
task_id: str | None = None,
platform_props: dict[str, str] | None = None,
platform_configs: dict | None = None,
test_mode: bool = False,
args: Optional[argparse.Namespace] = None,
args: argparse.Namespace | None = None,
):
"""
Initialize DataMimic with descriptor_path.
Expand Down
1 change: 1 addition & 0 deletions datamimic_ce/tasks/nested_key_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def _execute_generate(self, parent_context: GenIterContext) -> None:
Create new data for nestedkey
"""
nestedkey_type = self._statement.type
value: dict | list
if nestedkey_type == DATA_TYPE_LIST:
nestedkey_len = self._determine_nestedkey_length(context=parent_context)
value = []
Expand Down
2 changes: 1 addition & 1 deletion datamimic_ce/tasks/task_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def consume_product_by_page(
cache_key = f"{root_context.task_id}_{stmt.name}_{stmt.storage_id}_{stmt}"

# Get or create exporters
if cache_key not in root_context._task_exporters: # TODO: mypy issue [attr-defined]
if cache_key not in root_context._task_exporters: # TODO: mypy issue [attr-defined]
# Create the consumer set once
consumer_set = stmt.targets.copy()
# consumer_set.add(EXPORTER_PREVIEW) deactivating preview exporter for multi-process
Expand Down

0 comments on commit 192a796

Please sign in to comment.