-
Notifications
You must be signed in to change notification settings - Fork 213
Finished task1 Runway text-to-image node with properly integrated int… #71
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
Open
ElenkaSan
wants to merge
5
commits into
TheDesignFounder:main
Choose a base branch
from
ElenkaSan:elena-nurullina-task1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8d66a93
Finished task1 Runway text-to-image node with properly integrated int…
ElenkaSan bd16f4e
Changes have been made based on the comments provided
ElenkaSan febbd05
Updated logic by comments
ElenkaSan 409c61d
Removed fogotten Duplicate exception handling
ElenkaSan a222115
Removed some extra tests
ElenkaSan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| """ | ||
| Integration test for Runway Text2Img Node. | ||
| This test should be run when the full ComfyUI environment is available. | ||
| """ | ||
|
|
||
| import os | ||
| import sys | ||
| import pytest | ||
| import torch | ||
| import ast | ||
|
|
||
| def setup_module(): | ||
| """Set up the Python path to include ComfyUI modules.""" | ||
| # Add the ComfyUI root directory to Python path | ||
| comfyui_root = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) | ||
| if comfyui_root not in sys.path: | ||
| sys.path.insert(0, comfyui_root) | ||
|
|
||
| # Add the current directory to Python path | ||
| current_dir = os.path.dirname(os.path.dirname(__file__)) | ||
| if current_dir not in sys.path: | ||
| sys.path.insert(0, current_dir) | ||
|
|
||
| def test_runway_node_file_content(): | ||
| """Test that the RunwayText2ImgNode class exists in the file with expected content.""" | ||
| file_path = "comfy_api_nodes/nodes_runway.py" | ||
| if not os.path.exists(file_path): | ||
| pytest.skip(f"File {file_path} does not exist") | ||
|
|
||
| with open(file_path, 'r') as f: | ||
| content = f.read() | ||
|
|
||
| # Check if the class exists | ||
| assert "class RunwayText2ImgNode" in content, "RunwayText2ImgNode class not found" | ||
| print("RunwayText2ImgNode class found in file") | ||
|
|
||
| # Check for required methods and attributes | ||
| required_elements = [ | ||
| "RETURN_TYPES = (\"IMAGE\",)", | ||
| "CATEGORY = \"api node/image/Runway\"", | ||
| "RUNWAY_API_KEY" | ||
| ] | ||
|
|
||
| for element in required_elements: | ||
| assert element in content, f"Required element '{element}' not found in file" | ||
| print(f"Found required element: {element}") | ||
ElenkaSan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| print("RunwayText2ImgNode file contains expected content") | ||
|
|
||
| def test_runway_node_ast_parsing(): | ||
| """Test that the RunwayText2ImgNode can be parsed by Python AST.""" | ||
| file_path = "comfy_api_nodes/nodes_runway.py" | ||
| if not os.path.exists(file_path): | ||
| pytest.skip(f"File {file_path} does not exist") | ||
ElenkaSan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| try: | ||
| with open(file_path, 'r') as f: | ||
| content = f.read() | ||
|
|
||
| # Parse the file with AST to check syntax | ||
| tree = ast.parse(content) | ||
|
|
||
| # Find the RunwayText2ImgNode class | ||
| class_found = False | ||
| for node in ast.walk(tree): | ||
| if isinstance(node, ast.ClassDef) and node.name == "RunwayText2ImgNode": | ||
| class_found = True | ||
| print(f"Found RunwayText2ImgNode class in AST") | ||
|
|
||
| for item in node.body: | ||
| if isinstance(item, ast.FunctionDef) and item.name == "generate": | ||
| arg_names = [arg.arg for arg in item.args.args] | ||
| assert "prompt" in arg_names, "Missing 'prompt' argument" | ||
| assert "ratio" in arg_names, "Missing 'ratio' argument" | ||
| assert "unique_id" in arg_names, "Missing 'unique_id' argument" | ||
| print("Found generate() method and has required arguments") | ||
| break | ||
| else: | ||
| assert False, "generate() method not found" | ||
| break | ||
|
|
||
| assert class_found, "RunwayText2ImgNode class not found in AST" | ||
|
|
||
| except SyntaxError as e: | ||
| pytest.fail(f"Syntax error in {file_path}: {e}") | ||
| except Exception as e: | ||
| pytest.fail(f"Error parsing {file_path}: {e}") | ||
|
|
||
| def test_runway_node_mappings(): | ||
| """Test that the node mappings are properly defined.""" | ||
| file_path = "comfy_api_nodes/nodes_runway.py" | ||
| if not os.path.exists(file_path): | ||
| pytest.skip(f"File {file_path} does not exist") | ||
ElenkaSan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| with open(file_path, 'r') as f: | ||
| content = f.read() | ||
|
|
||
| # Check for node mappings | ||
| assert "NODE_CLASS_MAPPINGS" in content, "NODE_CLASS_MAPPINGS not found" | ||
| assert "RunwayText2ImgNode" in content, "RunwayText2ImgNode not in mappings" | ||
|
|
||
| # Check for display name mappings | ||
| assert "NODE_DISPLAY_NAME_MAPPINGS" in content, "NODE_DISPLAY_NAME_MAPPINGS not found" | ||
|
|
||
| print("Node mappings are properly defined") | ||
|
|
||
| def test_runway_node_import_with_mock(): | ||
| """Test importing the node with mocked dependencies.""" | ||
| file_path = "comfy_api_nodes/nodes_runway.py" | ||
| if not os.path.exists(file_path): | ||
| pytest.skip(f"File {file_path} does not exist") | ||
ElenkaSan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Mock the problematic imports | ||
| import unittest.mock as mock | ||
|
|
||
| with mock.patch.dict('sys.modules', { | ||
| 'utils.json_util': mock.MagicMock(), | ||
| 'server': mock.MagicMock(), | ||
| 'comfy': mock.MagicMock(), | ||
| 'comfy.comfy_types': mock.MagicMock(), | ||
| 'comfy.comfy_types.node_typing': mock.MagicMock(), | ||
| }): | ||
| try: | ||
| # Try to import the module | ||
| import importlib.util | ||
| spec = importlib.util.spec_from_file_location("nodes_runway", file_path) | ||
| module = importlib.util.module_from_spec(spec) | ||
| spec.loader.exec_module(module) | ||
|
|
||
| # Check if the class exists | ||
| assert hasattr(module, 'RunwayText2ImgNode'), "RunwayText2ImgNode not found in module" | ||
| print("RunwayText2ImgNode imported successfully with mocked dependencies") | ||
|
|
||
| except Exception as e: | ||
| print(f"Import with mock failed: {e}") | ||
| # This is not a failure, just informational | ||
| pass | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.