Commit graph

41 commits

Author SHA1 Message Date
Christophe Bornet
e91bcc2520
ref: Some ruff fixes from preview (#5420)
* Some ruff fixes from preview

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-28 21:25:35 +00:00
Christophe Bornet
4b0c42e520
feat: Bump blockbuster version to 1.5.5 (#5382)
Bump blockbuster version to 1.5.5
2024-12-20 13:45:06 +00:00
Christophe Bornet
3f0e383135
ref: Remove unused sync session_scope, with_session and engine (#5333)
Remove unused sync session_scope, with_session and engine
2024-12-18 20:52:06 +00:00
Christophe Bornet
8f6241be91
feat: Bump blockbuster version to 1.5.2 (#5331)
Bump blockbuster version to 1.5.2
2024-12-18 14:43:31 +00:00
Christophe Bornet
c3f36b69a2
feat: Bump blockbuster version to 1.5.0 (#5292)
* Bump blockbuster version to 1.5.0

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-12-17 23:26:18 +01:00
Christophe Bornet
624fa71709
feat: Activate sqlite blocking detection again (#5203)
Activate sqlite blocking detection again
2024-12-11 15:48:17 +00:00
Christophe Bornet
63bdcb9d03
ref: Make initialize_database async (#5163)
Make initialize_database async
2024-12-10 07:44:34 +01:00
Christophe Bornet
e545d12c40
fix: Use anyio for file operations in a few places (#5167)
Use anyio for file operations in a few places
2024-12-10 01:55:42 +00:00
Christophe Bornet
d58530c358
feat: Activate blockbuster Lock.aquire detection (#5157)
Activate blockbuster Lock.aquire detection

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-12-09 04:59:50 -08:00
Christophe Bornet
abf38e96e2
feat: Add sqlite to blocking call detection (#4376) 2024-12-09 11:48:48 +01:00
Christophe Bornet
c0b25fa651
ref: Remove some useless asyncio.to_thread (#5149)
Remove some useless asyncio.to_thread
2024-12-08 20:13:08 +01:00
Christophe Bornet
0b39554795
ref: Apply ruff rule RUF052 (#5089)
Apply ruff rule RUF052
2024-12-08 11:51:02 +00:00
Christophe Bornet
624a2dde5d
ref: Use AsyncSession in some tests (#5151) 2024-12-08 01:09:43 +00:00
Christophe Bornet
79b03ba133
fix: Use AsyncSession in memory (#4665) 2024-12-06 16:25:59 +00:00
Christophe Bornet
c1bd7c89c3
fix: Fix test_get_and_cache_all_types_dict (#5054) 2024-12-05 14:15:21 +01:00
Christophe Bornet
ab63ddddbd
ref: Use blockbuster package (#4777)
* Use blockbuster package

* Upgrade blockbuster to v1.1
2024-11-23 15:05:56 +00:00
Ítalo Johnny
e728e40561
fix: ensure unique flow names when assigning to superuser and avoid adding starter projects (#4751)
* fix: ensure unique flow names when assigning to superuser

* refactor: Creates a new function with logic to rename flows

* refactor: simplify function

* Extract STARTER_FOLDER constants to a separate module

* Filter orphaned flows by excluding those in the starter folder

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-11-21 09:35:32 -08:00
Christophe Bornet
a7aa3ab03f
fix: Use AsyncSession in delete_vertex_builds (#4653)
Use AsyncSession in delete_vertex_builds
2024-11-17 11:51:24 +00:00
Gabriel Luiz Freitas Almeida
7c0c881488
feat: Add option to deactivate tracing in service settings (#4527)
* Add option to deactivate tracing in service settings

* Add fixture to automatically deactivate tracing in tests using monkeypatch
2024-11-12 18:41:07 -08:00
Cristhian Zanforlin Lousa
73df2182de
fix: General Fixes and Improvements from v1.0.19.2 Fixes Branch (#4411)
* fix: update assistants client import (#4150)

* remove unnecessary patch

* remove unnecessary patch

* compatible release operator

* chore: add opensearch-py dependency (#4134)

Add opensearch-py dependency to pyproject.toml

* patch version

* lock

* lock some packages to speed up pip install

* langflow-base version

* fix: fix retrieverTool component (#4201)

♻️ (RetrieverTool.py): refactor build method signature to accept additional keyword arguments for future extensibility

* Fixed save modal not exiting

* fix: object has no attribute 'set_event_manager' (#4200)

* 🐛 (base.py): fix AttributeError by checking if custom_component has set_event_manager method before calling it

* 📝 (base.py): Import Component from langflow.custom to improve code readability and maintainability
♻️ (base.py): Refactor code to use isinstance() method for checking if custom_component is an instance of Component

* Refactor: Eliminate Global Variables for Improved Code Maintainability_fix_release (#4208)

Refactor: Eliminate Global Variables for Improved Code Maintainability

- Replaced global variables with local variables or class attributes.
- Enhanced code readability and reduced potential side effects.

* fix: Update example (#4204)

update example

* fix: avoids error NameError: name 'MAX_NUMBER_OF_FIELDS' is not defin… (#4203)

fix: avoids error NameError: name 'MAX_NUMBER_OF_FIELDS' is not defined and fixes build method

Co-authored-by: Edwin Jose <edwin.jose@datastax.com>

* fix: unexpected keyword argument 'code' -> SQLExecutor and SQLDatabase (#4230)

🔧 (SQLDatabase.py): update build method signature to accept additional keyword arguments for future extensibility
🔧 (SQLExecutor.py): update method signature to accept additional keyword arguments for future extensibility

* lock httptools to 0.6.4

* Move ChatInput import to within flow_component fixture in conftest.py

* Simplify error message formatting in test cases for data components

* Add readme to dockerfile

* build: dockerfile with entrypoint (#4062)

Adds a dockerfile with an entrypoint for use with Datastax Langflow

* fixes the leading v for checking out commits correctly

* fixes on more version checkout for docker build

*  (authContext.tsx): Add functionality to fetch global variables on authentication
🔧 (api.tsx): Replace universal-cookie import with react-cookie for consistency
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency
🔧 (use-get-global-variables.ts): Add check to only fetch global variables if user is authenticated
 (use-get-mutation-global-variables.ts): Add mutation function to fetch and update global variables
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency

* [autofix.ci] apply automated fixes

* revert changes to workflows

* upgrade lockfile

* update pyproject versions

* update lockfile again

* ⬆️ (pyproject.toml): upgrade langflow-base dependency to version 0.0.99

* ⬆️ (pyproject.toml): downgrade version from 0.0.99 to 0.0.97 to align with project requirements and dependencies.

* ⬆️ (pyproject.toml): downgrade langflow-base dependency version from 0.0.99 to 0.0.97 to resolve compatibility issues

* ⬆️ (uv.lock): downgrade langchain-core package version from 0.3.15 to 0.3.12 to resolve compatibility issues with dependencies

* ⬆️ (pyproject.toml): upgrade langflow-base dependency to version 0.0.99 to utilize the latest features and improvements

---------

Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: João <38133825+joaoguilhermeS@users.noreply.github.com>
Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
Co-authored-by: Jordan Frazier <122494242+jordanrfrazier@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-11-06 17:31:36 +00:00
Christophe Bornet
14b3117d6b
feat: Raise exception in tests when blocking code is called in event loop (#4293)
Raise exception in tests when blocking code is called in event loop
2024-11-02 17:03:31 +01:00
Ítalo Johnny
fadb20115d
test: add unit tests for routes (#4249) 2024-10-28 20:06:05 +00:00
Gabriel Luiz Freitas Almeida
e93397d118
chore: update dependencies and enable HTTP/2 support for AsyncClient in tests (#4173)
* Update dependencies in pyproject.toml: fastapi, httpx, python-multipart

* Enable HTTP/2 support for AsyncClient in test configurations
2024-10-23 13:02:06 +00:00
Christophe Bornet
6e39dedaae
ref: Rename component modules to lower case (ruff N999) (#4220)
* Rename component modules to lower case (ruff N999)

* git rename workaround (1/2)

* git rename workaround (2/2)

* Rollback changes on schema __init__

* Fix tests
2024-10-22 16:46:32 +00:00
Christophe Bornet
c85cd91e09
ref: Move get services out of API methods (#4216)
* Move get services out of API methods

* Rollback files API to be able to mock the dependency
2024-10-22 11:27:31 +00:00
Christophe Bornet
f96f2eaf8a
ref: Add ALL ruff rules for tests (#4183)
Add ALL ruff rules for tests
2024-10-19 20:41:37 +00:00
Christophe Bornet
45c8f98692
ref: Auto-fix ruff rules in tests (#4154) 2024-10-16 15:42:36 +00:00
Christophe Bornet
047077cee4
ref: Remove autouse from pytest client fixture (#4158)
Remove autouse from pytest client fixture
2024-10-15 22:55:10 +00:00
Christophe Bornet
eb53f66641
ref: Use pathlib in tests (#4159)
Use pathlib in tests
2024-10-15 17:51:50 +00:00
Gabriel Luiz Freitas Almeida
2adda780c9
tests: update env.py and conftest so tests use unique databases (#3654)
* Refactor Alembic environment script to simplify database connection logic and remove unused imports

* Refactor test client fixture to use TemporaryDirectory and UUID for database path

* Add `reload_engine` method to reinitialize the database engine

* Add cleanup steps to test fixtures to ensure proper resource management

- Added cleanup steps to various pytest fixtures to ensure temporary directories, database entries, and other resources are properly cleaned up after tests.
- Modified fixtures to use `yield` for better resource management.
- Ensured database connections are closed and tables are dropped after tests.
- Improved temporary directory handling with context managers.

* Add unit test to verify return type of list_flows method in custom component

* Refactor tests in `test_custom_component.py` to remove unused imports and fixtures, and update existing fixtures for consistency.

* Add debug checks for user existence in `test_user_waiting_for_approval` test

* Fix import order and add flow_id validation in transaction handling

- Corrected the import order in `utils.py`.
- Added validation for `flow_id` in the transaction handling logic to ensure it is set correctly.

* Add function to delete transactions by flow ID in CRUD module

* Add cleanup for transactions and vertex builds in test teardown

- Introduced `_delete_transactions_and_vertex_builds` function to remove transactions and vertex builds associated with a user.
- Updated `user` fixture to call the new cleanup function before deleting the user.

* Refactor flow_id assignment logic in `utils.py` to improve readability and correctness

* [autofix.ci] apply automated fixes

* Refactor test to use pytest's tmp_path fixture for temporary directory creation

* Convert `test_user_waiting_for_approval` to an async test function

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-10 11:45:11 +00:00
Gabriel Luiz Freitas Almeida
4221fa40e6
refactor: deactivate caching if a component is part of a cycle (#3694)
* Set `_has_cycle_edges` to `True` for source and target vertices in cycle edges

* feat: Add `has_cycle_edges` method to Vertex class

The `has_cycle_edges` method is added to the `Vertex` class to check if the vertex has any cycle edges. Additionally, the `instantiate_component` method is updated to use the `initialize.loading.instantiate_class` function for custom component instantiation.

* Add `apply_on_outputs` method to Vertex for applying functions to outputs

* Add utility to find vertices in cycles within a directed graph

- Implement `find_cycle_vertices` function to identify all vertices that are part of cycles in a directed graph.
- Utilize depth-first search (DFS) to detect cycles and collect vertices involved in those cycles.

* Add unit tests for `find_cycle_vertices` utility function in graph module

* Add method to set cache for vertices in cycle

- Introduced `_set_cache_to_vertices_in_cycle` method to enable caching for vertices involved in cycles.
- Added `find_cycle_vertices` import to support the new method.
- Refactored vertex instantiation into `_instantiate_components_in_vertices` method for better code organization.

* refactor: Update caching logic for vertices in cycles

Refactor the `_set_cache_to_vertices_in_cycle` method to improve caching logic for vertices involved in cycles. Instead of setting the `cache` attribute to `True`, it is now set to `False` for better clarity and consistency. This change ensures that the cache is properly handled for vertices in cycles.

* Refactor `find_cycle_vertices` to use NetworkX for cycle detection

* Refactor `find_cycle_vertices` tests to remove entry point parameter and add new test case

- Removed the `entry_point` parameter from all test cases for `find_cycle_vertices`.
- Added a new parameterized test case `test_handle_two_inputs_in_cycle` to verify handling of cycles with two inputs.

* Disable cache in cycle: Update `apply_on_outputs` to handle empty outputs in `base.py`

* Add unit test to ensure output cache is disabled in graph cycles

* Add unit test for graph cyclicity with prompt components and OpenAI integration

- Introduce `test_updated_graph_with_prompts` to validate graph cyclicity and execution.
- Integrate `PromptComponent`, `OpenAIModelComponent`, and `ConditionalRouterComponent` in the test.
- Ensure graph execution with a maximum of 20 iterations and cache disabled.
- Validate the presence of expected output vertices in the results.

* Convert `_instantiate_components_in_vertices` to async and disable cache in cycle vertices

* Add default value handling for cycle edges in vertex component

- Introduced `default_value` to handle cases where edges are cycles and target parameters are present.
- Ensured that `default_value` is returned if defined, preventing errors when the component is not built.

* Switch from os.environ to os.getenv for API key retrieval in test_cycles.py

* Add __repr__ method to Edge class to indicate cycle edges with a symbol

* Refactor test_cycles.py to streamline component initialization and update assertions

- Simplified component initialization using method chaining.
- Corrected router input and message parameters to use openai_component_1.
- Updated assertions to check for correct output IDs.

* Refactor test_cycles.py to streamline component initialization and update assertions

* Refactor test to use custom serialization method instead of pickle

* Add cycle_vertices property to optimize cycle detection in graph

- Introduced `_cycle_vertices` attribute to store vertices involved in cycles.
- Added `cycle_vertices` property to compute and cache cycle vertices.
- Updated edge creation logic to use `cycle_vertices` for cycle detection.

* Enhance error message in `types.py` to include component ID for better debugging

* Refactor test_cycles.py to update graph configuration and assertions

- Changed router operator from "equals" to "contains".
- Consolidated chat output to a single component.
- Updated graph construction to use a single chat output.
- Replaced `_snapshot` with `get_snapshot` for graph state capture.
- Adjusted assertions to reflect the updated graph structure and outputs.

* Add api_key_required marker to test_updated_graph_with_prompts test

* Add validation to require max_iterations for cyclic graphs

* run ruff

- Refactored error message handling in `base.py` for cyclic graphs.
- Optimized cycle vertex extraction in `utils.py` by using set comprehension.

* Comment out tests for loading flow from JSON in test_loading.py

* Refactor test fixture for webhook flow creation in conftest.py

* Update unit tests to reflect new webhook flow structure in vertices endpoints

* Temporarily disable tests for loading Langchain objects with and without cached sessions

* Disable caching in vector store and OpenAI model components
2024-10-02 18:05:20 +00:00
Gabriel Luiz Freitas Almeida
6febae599b
tests: update tests to use httpx.AsyncClient (#3984)
* Add async support and dependencies to pyproject.toml files

- Added `asgi-lifespan>=2.1.0` to dependencies.
- Configured `asyncio_mode` and `asyncio_default_fixture_loop_scope` for pytest.
- Updated `tool.uv` section with `asgi-lifespan` in dev-dependencies.

* Convert test fixtures to async and use AsyncClient for HTTP requests

* Handle 'ImportFrom' nodes in AST validation to support module attribute imports

* Convert test cases to use async HTTP client

- Updated test cases in `test_database.py`, `test_endpoints.py`, `test_user.py`, `test_variable.py`, `test_files.py`, `test_chat_endpoint.py`, `test_misc.py`, `test_messages_endpoints.py`, `test_api_key.py`, `test_webhook.py`, and `test_login.py` to use `httpx.AsyncClient` instead of `fastapi.TestClient`.
- Modified test functions to be asynchronous and use `await` for HTTP requests.
- Adjusted fixtures and helper functions to support asynchronous operations.
- Ensured consistency in endpoint paths and request methods across all test cases.

* Refactor string concatenation to f-string in test_chat_endpoint.py

* [autofix.ci] apply automated fixes

* Refactor import validation to use pattern matching for AST nodes

* Set `startup_timeout` and `shutdown_timeout` to `None` in `LifespanManager` for test files.

* Convert test functions to async in `test_messages_endpoints.py`

* Add `api_key_required` marker to assistant component tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-02 10:21:52 -07:00
Christophe Bornet
7e3d470845
ref: Add ruff rules for bugbear (B) (#3983)
Add ruff rules for bugbear (B)
2024-10-02 18:55:51 +02:00
Gabriel Luiz Freitas Almeida
270f609fe7
refactor: enhance tool creation logic and add FeatureFlags (#3662)
* Add `required_inputs` field to `Output` model in `base.py`

* Refactor ComponentTool to ComponentToolkit and enhance tool creation logic

- Replaced `ComponentTool` with `ComponentToolkit` to better encapsulate component-related tools.
- Introduced `build_description` and `_build_output_function` helper functions for dynamic tool creation.
- Updated tool initialization to handle multiple outputs and required inputs using `StructuredTool`.
- Improved schema creation for tool arguments based on component inputs.

* Refactor `to_tool` method to `to_toolkit` to use `ComponentToolkit` instead of `ComponentTool`

* Refactor `ComponentTool` to `ComponentToolkit` in unit tests

- Updated import statements to reflect the new `ComponentToolkit` class.
- Modified test logic to use `ComponentToolkit` for retrieving tools.
- Adjusted assertions to match the new structure and output format.
- Ensured compatibility with `Message` schema for output validation.

* Refactor `test_component_to_tool` to validate `ComponentToolkit` and tool properties

* Refactor `build_description` to include input types in the output format

* Add method to set required inputs for outputs based on method analysis

- Introduced `_set_output_required_inputs` method to determine and set required inputs for each output by analyzing the method's source code.
- Added necessary imports (`ast` and `dedent`) to support the new functionality.

* Update test to assert full tool description in test_component_to_tool.py

* Add unit tests for verifying required inputs of various components

- Added tests to ensure that required inputs for outputs are present in the inputs of `ChatInput`, `ChatOutput`, `SequentialTaskComponent`, `ToolCallingAgentComponent`, and `OpenAIModelComponent`.
- Included helper functions to check if required inputs are in inputs and to assert that all outputs have different required inputs.

* Add RequiredInputsVisitor to identify required inputs in AST nodes

- Introduced RequiredInputsVisitor class to traverse AST nodes and collect required inputs.
- The visitor checks for 'self' attributes matching the provided inputs and adds them to the required_inputs set.

* Refactor required inputs extraction using `RequiredInputsVisitor`

* Add feature flags configuration for toolkit output in settings

* Add toolkit output handling based on feature flag in custom component utils

* Add method to append 'component_as_tool' output in custom component

* Add unit test for toolkit output feature flag in custom component

* Add utility functions for lazy loading and instantiating input types in langflow

- Introduced `get_InputTypesMap` for lazy loading of `InputTypesMap`.
- Added `instantiate_input` function to create instances of input types dynamically.
- Included type checking and error handling for invalid input types.

* Refactor input instantiation logic and update imports

- Removed `instantiate_input` function from `inputs.py` and moved it to `utils.py`.
- Updated imports in `base.py` to reflect the new location of `instantiate_input`.
- Added missing import for `Callable` in `base.py`.

* Refactor import statement to use `instantiate_input` from `langflow.inputs.utils` in test_inputs.py

* Add TOOL_OUTPUT_NAME constant to tools module

* Add type checking and TOOL_OUTPUT_NAME filter in ComponentToolkit

- Introduced `TYPE_CHECKING` for type hints to avoid circular imports.
- Added `TOOL_OUTPUT_NAME` constant to filter specific outputs in `ComponentToolkit`.
- Updated type annotations to use forward references.

* Refactor component toolkit import to avoid circular dependency and use constant for tool output name

* Refactor `ComponentToolkit` class to remove inheritance from `BaseToolkit` and add an initializer for `component`

* Add unit test for ComponentToolkit in test_component_to_tool

- Added `test_component_to_tool_has_no_component_as_tool` to verify that `ComponentToolkit` correctly initializes with a `ChatInput` component and returns the expected tools.

* Refactor toolkit output handling to `custom_component` module

* fix: mypy errors union-attr and arg-type

* Add 'OTHER' field type to schema in langflow/io/schema.py

* Add tool name formatting to ComponentToolkit to ensure valid characters

* Refactor toolkit output handling and add type hint for `to_toolkit` method

* Add `is_interface_component` attribute to vertex types and update import order

* Add tests for ToolCallingAgentComponent and ChatOutput with API key handling

- Updated `test_component_tool` to reflect new description format.
- Added `test_component_tool_with_api_key` to test `ToolCallingAgentComponent` with `ChatOutput` and OpenAI API key.
- Enabled `add_toolkit_output` feature flag for testing.

* Refactor `_find_matching_output_method` to accept `input_name` parameter for more precise input-output matching

* Replace ValueError with warning in build_description function

* use chat_output component directly in set

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 3/3)

* Refactor: Reorder method calls in `__init__` for logical consistency

Moved `set_class_code` method call to ensure output types and required inputs are set before class code initialization.

* Update _format_tool_name to allow '.' in tool names

* Refactor `_format_tool_name` to remove non-alphanumeric characters

* Update test assertions for component tool name and output mapping

* Handle case where 'required_inputs' is empty in 'component_tool.py'

* Refactor import statements for better readability in `base.py`

* [autofix.ci] apply automated fixes

* Add noqa comment to suppress import warning and re-add Any import in base.py

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-01 20:58:51 +00:00
Gabriel Luiz Freitas Almeida
35d81b7e34
feat: Add components_only parameter to filter flows by components in API endpoint (#3932)
* Add fixture for creating flow component in tests

* Add test for reading flows with components only in test_database.py

* Add `components_only` parameter to filter flows by components in API endpoint
2024-09-27 18:18:24 +00:00
Gabriel Luiz Freitas Almeida
fcf780bf42
tests: optimize test durations and refactor test fixtures (#3713)
* Refactor test fixtures and imports for optimization

- Reordered and optimized imports in `conftest.py`.
- Changed return statements to yield in `basic_graph` and `create_webhook` fixtures for better resource management.
- Added cleanup step to `create_webhook` fixture to delete created webhook after test completion.

* Refactor imports and add placeholder client fixture in test_ChatOllama_component.py

* Add pytest fixture 'client' to test_graph.py

* Add pytest fixture 'client' to test_callback_graph.py for test optimization

* Add 'unit_tests_looponfail' target to Makefile for running unit tests with loop-on-fail option

* Optimize test durations and update test cases in various modules
2024-09-06 14:03:27 -07:00
Nicolò Boschi
96872f3aa5
chore: refactor and add components integration tests (#3607)
* improve inegration tests

* add fixes

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-02 15:21:47 +02:00
Gabriel Luiz Freitas Almeida
9c8dd8e1f0
chore: upgrade type annotations in graph and custom modules (#3591)
* refactor(tests): update import statements in conftest.py to use collections.abc module for better compatibility and maintainability

* run pyupgrade on graph module

* [autofix.ci] apply automated fixes

* refactor(attributes.py): change import statement from 'typing.Callable' to 'collections.abc.Callable' for better compatibility
refactor(code_parser.py): update type annotations to use '|' for Union types for better readability
refactor(base_component.py): update type annotations to use '|' for Union types for better readability
refactor(component.py): change import statement from 'typing.Callable' to 'collections.abc.Callable' for better compatibility
refactor(component.py): update type annotations to use '|' for Union types for better readability
refactor(component.py): update type annotations to use 'list' instead of 'List' for consistency

refactor(custom_component.py): update typing imports and annotations for better readability and consistency

refactor(utils.py): change type hint 'List' to 'list' for consistency and compatibility with Python 3.9

* run make format

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-28 18:48:24 +00:00
Nicolò Boschi
f311a6db54
feat: ui build in one single http request (#3020)
* feat: ui build in one single http request

* fix use session_id

* fix frozen

* [autofix.ci] apply automated fixes

* prettier

* add tests

* add tests

* fix mypy

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-02 06:53:34 -07:00
Gabriel Luiz Freitas Almeida
77cc789e62
refactor: separate initialization of nodes and edges in test_graph.py (#2828)
* refactor: move test_graph.py

* refactor: allow Graph to be initialized with no nodes and edges

The Graph class in `base.py` was refactored to separate the initialization of nodes and edges into a separate method called `add_nodes_and_edges()`. This improves code readability and maintainability by organizing the code logic more effectively.

* refactor: separate initialization of nodes and edges in get_graph()

The `get_graph()` function in `conftest.py` was refactored to separate the initialization of nodes and edges. This improves code readability and maintainability by organizing the code logic more effectively.

* refactor: separate initialization of nodes and edges in test_graph.py

* refactor: separate initialization of nodes and edges in base.py

The `add_node()` and `add_edge()` methods were added to the `Graph` class in `base.py` to separate the initialization of nodes and edges. This improves code readability and maintainability by organizing the code logic more effectively.
2024-07-22 16:48:29 -03:00
Gabriel Luiz Freitas Almeida
0122a50a35
refactor: move tests folder structure and update pytest commands (#2785)
* refactor: move tests folder to src/backend

* chore(Makefile): update pytest commands to run tests from the correct directory paths for unit and integration tests

* refactor: update file path in test_custom_component.py

The file path in the test_custom_component.py file has been updated to use the correct relative path to the component_multiple_outputs.py file. This change ensures that the test code can access the correct file and improves the reliability of the test.
2024-07-18 15:19:43 +00:00
Renamed from tests/conftest.py (Browse further)