sdg-hub 0.5.1__py3-none-any.whl → 0.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sdg_hub/_version.py +2 -2
- sdg_hub/core/blocks/base.py +60 -58
- sdg_hub/core/blocks/filtering/column_value_filter.py +29 -16
- sdg_hub/core/blocks/llm/__init__.py +0 -2
- sdg_hub/core/blocks/llm/llm_chat_block.py +42 -36
- sdg_hub/core/blocks/llm/llm_parser_block.py +13 -59
- sdg_hub/core/blocks/llm/prompt_builder_block.py +15 -10
- sdg_hub/core/blocks/llm/text_parser_block.py +14 -61
- sdg_hub/core/blocks/transform/duplicate_columns.py +9 -8
- sdg_hub/core/blocks/transform/index_based_mapper.py +29 -15
- sdg_hub/core/blocks/transform/json_structure_block.py +16 -13
- sdg_hub/core/blocks/transform/melt_columns.py +13 -12
- sdg_hub/core/blocks/transform/rename_columns.py +20 -9
- sdg_hub/core/blocks/transform/text_concat.py +20 -21
- sdg_hub/core/blocks/transform/uniform_col_val_setter.py +6 -5
- sdg_hub/core/flow/base.py +139 -106
- sdg_hub/core/flow/checkpointer.py +34 -36
- sdg_hub/core/flow/validation.py +4 -4
- sdg_hub/core/utils/datautils.py +52 -54
- sdg_hub/core/utils/flow_metrics.py +9 -6
- sdg_hub/flows/qa_generation/document_grounded_qa/multi_summary_qa/multilingual/japanese/flow.yaml +1 -0
- {sdg_hub-0.5.1.dist-info → sdg_hub-0.6.1.dist-info}/METADATA +5 -9
- {sdg_hub-0.5.1.dist-info → sdg_hub-0.6.1.dist-info}/RECORD +26 -28
- sdg_hub/core/blocks/llm/llm_chat_with_parsing_retry_block.py +0 -771
- sdg_hub/core/utils/temp_manager.py +0 -57
- {sdg_hub-0.5.1.dist-info → sdg_hub-0.6.1.dist-info}/WHEEL +0 -0
- {sdg_hub-0.5.1.dist-info → sdg_hub-0.6.1.dist-info}/licenses/LICENSE +0 -0
- {sdg_hub-0.5.1.dist-info → sdg_hub-0.6.1.dist-info}/top_level.txt +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
"""Utilities for managing temporary files and directories used by the flow."""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from typing import Optional, Union
|
|
8
|
-
|
|
9
|
-
# Standard
|
|
10
|
-
import os
|
|
11
|
-
import shutil
|
|
12
|
-
import tempfile
|
|
13
|
-
|
|
14
|
-
TEMP_ROOT_DIR_NAME = ".tmp_sdg_buffer"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def _get_temp_root() -> Path:
|
|
18
|
-
root = Path.cwd() / TEMP_ROOT_DIR_NAME
|
|
19
|
-
root.mkdir(parents=True, exist_ok=True)
|
|
20
|
-
return root
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _format_prefix(prefix: str) -> str:
|
|
24
|
-
return f"{prefix}_" if prefix and not prefix.endswith("_") else prefix
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def create_temp_dir(prefix: str = "tmp", suffix: str = "") -> Path:
|
|
28
|
-
"""Create a unique temporary directory."""
|
|
29
|
-
root = _get_temp_root()
|
|
30
|
-
name = tempfile.mkdtemp(prefix=_format_prefix(prefix), suffix=suffix, dir=root)
|
|
31
|
-
return Path(name)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def create_temp_file(prefix: str = "tmp", suffix: str = "") -> Path:
|
|
35
|
-
"""Create a unique temporary file."""
|
|
36
|
-
root = _get_temp_root()
|
|
37
|
-
fd, name = tempfile.mkstemp(prefix=_format_prefix(prefix), suffix=suffix, dir=root)
|
|
38
|
-
os.close(fd)
|
|
39
|
-
return Path(name)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def cleanup_path(path: Optional[Union[str, os.PathLike]]) -> None:
|
|
43
|
-
"""Remove a temporary file or directory if it exists."""
|
|
44
|
-
if not path:
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
target = Path(path)
|
|
48
|
-
if not target.exists():
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
if target.is_dir():
|
|
52
|
-
shutil.rmtree(target, ignore_errors=True)
|
|
53
|
-
else:
|
|
54
|
-
try:
|
|
55
|
-
target.unlink()
|
|
56
|
-
except FileNotFoundError:
|
|
57
|
-
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|