Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kn/x #35

Merged
merged 2 commits into from
Jan 18, 2025
Merged

Kn/x #35

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
.DS_Store
dataset_tools.egg-info
dataset_tools.dataset_tools.egg-info
build
build
dataset_tools/__pycache__/__init__.cpython-310.pyc
dataset_tools/__pycache__/access_disk.cpython-310.pyc
dataset_tools/__pycache__/correct_types.cpython-310.pyc
dataset_tools/__pycache__/logger.cpython-310.pyc
dataset_tools/__pycache__/main.cpython-310.pyc
dataset_tools/__pycache__/metadata_parser.cpython-310.pyc
dataset_tools/__pycache__/ui.cpython-310.pyc
dataset_tools/__pycache__/widgets.cpython-310.pyc
51 changes: 48 additions & 3 deletions dataset_tools/correct_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
"""確認 Data Type"""

from ast import Constant
from typing_extensions import TypedDict, Annotated, List

from platform import python_version_tuple

if float(python_version_tuple()[0]) == 3.0 and float(python_version_tuple()[1]) <= 12.0:
from typing_extensions import TypedDict, Annotated, List, Union
else:
from typing import TypedDict, Annotated, List, Union

Check warning

Code scanning / Pylint (reported by Codacy)

No name 'Annotated' in module 'typing' Warning

No name 'Annotated' in module 'typing'

Check warning

Code scanning / Pylint (reported by Codacy)

No name 'TypedDict' in module 'typing' Warning

No name 'TypedDict' in module 'typing'

from pydantic import TypeAdapter, BaseModel, Field, AfterValidator, field_validator, ValidationError

Expand Down Expand Up @@ -71,10 +77,14 @@
"CLIPTextEncodeSD3",
"CLIPTextEncodeSDXL",
"CLIPTextEncodeHunyuanDiT",
"CLIPTextEncodePixArtAlpha",
"CLIPTextEncodeSDXLRefiner",
"WildcardEncode //Inspire",
"ImpactWildcardProcessor",
"CLIPTextEncode",
"ImpactWildcardEncodeCLIPTextEncode",
]
PROMPT_LABELS = ["Positive prompt", "Negative prompt", "Prompt"]

IGNORE_KEYS = [
"type",
"link",
Expand All @@ -84,6 +94,29 @@
"size",
]

DATA_KEYS = {
"class_type": "inputs",
"nodes": "widget_values",
}
PROMPT_NODE_FIELDS = {
"text",
"t5xxl",
"clip-l",
"clip-g",
"mt5",
"mt5xl",
"bert",
"clip-h",
"wildcard",
"string",
"positive",
"negative",
"text_g",
"text_l",
"wildcard_text",
"populated_text",
}


EXC_INFO: bool = LOG_LEVEL != "i"

Expand All @@ -109,7 +142,18 @@

class NodeDataMap(TypedDict):
class_type: str
inputs: dict
inputs: Union[dict, float]


class NodeWorkflow(TypedDict):
Dismissed Show dismissed Hide dismissed

Check warning

Code scanning / Pylint (reported by Codacy)

Missing class docstring Warning

Missing class docstring
last_node_id: int
last_link_id: Union[int, dict]
nodes: list
links: list
groups: list
config: dict
extra: dict
version: float


class BracketedDict(BaseModel):
Expand All @@ -130,6 +174,7 @@
"""

data = TypeAdapter(NodeDataMap)
workflow = TypeAdapter(NodeWorkflow)


class ListOfDelineatedStr(BaseModel):
Expand Down
10 changes: 5 additions & 5 deletions dataset_tools/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rich.logging import RichHandler
from rich.style import Style

from dataset_tools.correct_types import LOG_LEVEL, EXC_INFO
from dataset_tools.correct_types import EXC_INFO, LOG_LEVEL


msg_init = None # pylint: disable=invalid-name
Expand Down Expand Up @@ -82,9 +82,9 @@
return wrapper


def debug_message(message, *args):
logger.debug("%s", f"{message} {args}")
def debug_message(*args):

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning

Missing function docstring
logger.debug(args)


def info_monitor(message, *args):
logger.info("%s", f"{message} {args}")
def info_monitor(*args):

Check warning

Code scanning / Pylint (reported by Codacy)

Missing function docstring Warning

Missing function docstring
logger.info(args, exc_info=EXC_INFO)
Loading
Loading