Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install torch
- uses: comfy-org/node-diff@main
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Python File",
"type": "debugpy",
"request": "launch",
"program": "${file}"
}
]
}
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.defaultInterpreterPath": "${workspaceFolder}/../../venv/bin/python",
"python.analysis.extraPaths": [
"${workspaceFolder}/src",
"${workspaceFolder}",
"${workspaceFolder}/../../"
],
"python.testing.cwd": "${workspaceFolder}",
"python.autoComplete.extraPaths": [
"${workspaceFolder}/src",
"${workspaceFolder}",
"${workspaceFolder}/../../"
]
}
85 changes: 85 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Tests (pytest)",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m pytest",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Lint (ruff)",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m ruff check .",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Format (ruff)",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m ruff format .",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Type Check (mypy)",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m mypy .",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Run Coverage",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m pytest --cov=src",
"group": "test",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Pre-commit Run All",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m pre_commit run --all-files",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
},
{
"label": "Bump Version (patch)",
"type": "shell",
"command": "${workspaceFolder}/../../venv/bin/python -m bump_my_version bump patch",
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
}
]
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ String manipulation nodes:
- **Text modification**: concat, count, replace, strip, lstrip, rstrip, removeprefix, removesuffix
- **Encoding/escaping**: decode, encode, escape, unescape, format_map

### TENSOR

PyTorch tensor manipulation nodes:

- **Creation**: Tensor Create (from numbers, lists, or other tensors)
- **Arithmetic**: Tensor Binary Op (add, subtract, multiply, divide, power, remainder, floor_divide)
- **Functions**: Tensor Unary Op (abs, neg, exp, log, sin, cos, sqrt, sigmoid, relu)
- **Reshaping**: Tensor Reshape, Tensor Permute (dims)
- **Access**: Tensor Slice (supports Python-style slice strings like `0:10, :, 5`)
- **Combined**: Tensor Join (concatenate or stack)
- **Analysis**: Tensor Info (returns shape, dtype, device)

### Time

Date and time manipulation nodes:
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ build-backend = "setuptools.build_meta"

[project]
name = "basic_data_handling"
version = "1.3.0"
version = "1.4.0"
description = """Basic Python functions for manipulating data that every programmer is used to, lightweight with no additional dependencies.

Supported data types:
- ComfyUI native: BOOLEAN, FLOAT, INT, STRING, and data lists
- Python types as custom data types: DICT, LIST, SET, DATETIME, TIMEDELTA
- PyTorch: TENSOR

Feature categories:
- Boolean logic operations
Expand All @@ -22,7 +23,8 @@ Feature categories:
- String manipulation
- File system path handling, including STRING, IMAGE and MASK load and save
- SET operations
- time and date handling"""
- time and date handling
- PyTorch Tensor manipulation (arithmetic, slicing, reshaping)"""
authors = [
{name = "StableLlama"}
]
Expand Down Expand Up @@ -58,7 +60,7 @@ Icon = ""
minversion = "8.0"
pythonpath = [
"src",
#"../..", # Path to parent directory containing comfy module
"../..", # Path to parent directory containing comfy module
"."
]
testpaths = [
Expand Down
4 changes: 3 additions & 1 deletion src/basic_data_handling/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from . import (boolean_nodes, casting_nodes, comparison_nodes, control_flow_nodes,
data_list_nodes, dict_nodes, float_nodes, int_nodes, list_nodes,
math_nodes, math_formula_node, path_nodes, regex_nodes, set_nodes,
string_nodes, time_nodes)
string_nodes, tensor_nodes, time_nodes)

NODE_CLASS_MAPPINGS = {}
NODE_CLASS_MAPPINGS.update(boolean_nodes.NODE_CLASS_MAPPINGS)
Expand All @@ -19,6 +19,7 @@
NODE_CLASS_MAPPINGS.update(math_nodes.NODE_CLASS_MAPPINGS)
NODE_CLASS_MAPPINGS.update(math_formula_node.NODE_CLASS_MAPPINGS)
NODE_CLASS_MAPPINGS.update(string_nodes.NODE_CLASS_MAPPINGS)
NODE_CLASS_MAPPINGS.update(tensor_nodes.NODE_CLASS_MAPPINGS)
NODE_CLASS_MAPPINGS.update(time_nodes.NODE_CLASS_MAPPINGS)

NODE_DISPLAY_NAME_MAPPINGS = {}
Expand All @@ -37,4 +38,5 @@
NODE_DISPLAY_NAME_MAPPINGS.update(math_nodes.NODE_DISPLAY_NAME_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(math_formula_node.NODE_DISPLAY_NAME_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(string_nodes.NODE_DISPLAY_NAME_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(tensor_nodes.NODE_DISPLAY_NAME_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(time_nodes.NODE_DISPLAY_NAME_MAPPINGS)
Loading