gradio/test
Shubham raj 6ebf0cedf5
Add support for diffuser pipelines in gr.Interface.from_pipeline(). (#7265)
* Add support for StableDiffusionPipeline

* Add support for Stable Diffusion pipelines in interface.from_pipeline(), import transformers and diffusers conditionally

* add changeset

* refactor: create helpers method to handle transformers and diffusers pipelines and refactored load from pipeline to use helper methods.

* Update test requirements.in, and generated requirements.txt after adding diffusers as dependency

* Fix reportPrivateImportUsage on diffusers pipelines

* Format code using ruff

* PIL is required library so moved it out of if block

* Add return statement to every if block and fix typo

* check module name of pipeline to decide how to handle that pipeline

* refactored if statements in pipeline_helper module

* exclude gradio from test requirements

* update tests requirements.txt using pip-compile --upgrade

* fix failing typechecks

* Add unit tests for one transformer and diffuser load from pipeline

* Refactor code to return dict from every if branch and replace all elifs

* Update requirements.txt using pip-compile

* Update requirements file

* Update test requirements file

* Add unit tests for handle transfomers and diffusers pipelines functions present in pipelines_helpers.py

* Add support for StableDiffusionPipeline

* Add support for Stable Diffusion pipelines in interface.from_pipeline(), import transformers and diffusers conditionally

* add changeset

* refactor: create helpers method to handle transformers and diffusers pipelines and refactored load from pipeline to use helper methods.

* Update test requirements.in, and generated requirements.txt after adding diffusers as dependency

* Fix reportPrivateImportUsage on diffusers pipelines

* Format code using ruff

* PIL is required library so moved it out of if block

* Add return statement to every if block and fix typo

* check module name of pipeline to decide how to handle that pipeline

* refactored if statements in pipeline_helper module

* exclude gradio from test requirements

* update tests requirements.txt using pip-compile --upgrade

* fix failing typechecks

* Add unit tests for one transformer and diffuser load from pipeline

* Refactor code to return dict from every if branch and replace all elifs

* Update requirements.txt using pip-compile

* Update requirements file

* Update test requirements file

* Add unit tests for handle transfomers and diffusers pipelines functions present in pipelines_helpers.py

* remove gradio from test requirements

* remove ap.py

* formatting and minor cleanup

* changes

* update version

* Version

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2024-03-08 11:53:38 -08:00
..
golden
test_files Rotate Images to Upright Position in preprocess (#6676) 2023-12-07 13:16:48 -05:00
tmp
__init__.py
conftest.py Control which files get moved to cache with gr.set_static_paths (#7618) 2024-03-07 15:39:07 -05:00
README.md fixed typo (#6896) 2023-12-29 08:17:57 -08:00
requirements.in Add support for diffuser pipelines in gr.Interface.from_pipeline(). (#7265) 2024-03-08 11:53:38 -08:00
requirements.txt Add support for diffuser pipelines in gr.Interface.from_pipeline(). (#7265) 2024-03-08 11:53:38 -08:00
test_analytics.py Update ruff to 0.1.13, enable more rules, fix issues (#7061) 2024-02-01 11:32:40 -08:00
test_api_info.py Add show_api parameter to events, and fix gr.load(). Also makes some minor improvements to the "view API" page when running on Spaces (#6846) 2023-12-22 11:59:02 -08:00
test_blocks.py Control which files get moved to cache with gr.set_static_paths (#7618) 2024-03-07 15:39:07 -05:00
test_buttons.py Allow mounted Gradio apps to work with external / arbitrary authentication providers (#7557) 2024-03-05 12:41:39 -08:00
test_chat_interface.py Fixes issue 5781: Enables specifying a caching directory for Examples (#6803) 2023-12-18 17:07:38 -08:00
test_components.py Refactor example_inputs(), separating its logic into two separate methods: example_payload() and example_value() (#7620) 2024-03-06 19:37:14 +00:00
test_custom_component_compatibility.py Update ruff to 0.1.13, enable more rules, fix issues (#7061) 2024-02-01 11:32:40 -08:00
test_events.py Add concurrency_limit to ChatInterface, add IDE support for concurrency_limit (#6653) 2023-12-04 17:19:53 -05:00
test_external.py fix flaky python tests (#7617) 2024-03-05 16:34:24 -08:00
test_flagging.py
test_gradio_component_cli.py Make set_documentation_group a no-op (#7377) 2024-02-09 16:53:21 -08:00
test_helpers.py Refactor examples so they accept data in the same format as is returned by function, rename .as_example() to .process_example() (#6933) 2024-01-10 16:35:25 -08:00
test_interfaces.py Update ruff to 0.1.13, enable more rules, fix issues (#7061) 2024-02-01 11:32:40 -08:00
test_networking.py
test_pipelines.py Add support for diffuser pipelines in gr.Interface.from_pipeline(). (#7265) 2024-03-08 11:53:38 -08:00
test_processing_utils.py Fixes method to resolve the root URLs (#7565) 2024-03-04 07:52:49 -08:00
test_queueing.py Python client properly handles hearbeat and log messages. Also handles responses longer than 65k (#6693) 2023-12-13 17:47:06 -05:00
test_reload.py
test_routes.py Use x-forwarded-host header to determine the root url, and let users provide a full root_path to override the automatically determined root url (#7641) 2024-03-08 10:15:11 -08:00
test_theme_sharing.py Allow mounted Gradio apps to work with external / arbitrary authentication providers (#7557) 2024-03-05 12:41:39 -08:00
test_tunneling.py
test_utils.py Fix the root_url logic for streaming files (#7614) 2024-03-05 15:21:45 -08:00

Backend Testing Guidelines

  • All the tests should test Backend functionalities. Frontend functionalities and e2e tests are done in Frontend.
  • Make use of pytest fixtures whenever it is possible. With fixtures, objects with high initialize durations are reused within tests, ex. a client session.
  • All testdata resides within _gradio/test_data and all test_files reside within test/test_files.
  • When doing network operations do not forget to make use of async to make tests faster.
  • Have clear class and function naming within the tests.
  • Short descriptions within test functions are great.
  • Library function docstrings is expected to contain an example, please add missing docstrings to the library while you are writing tests the related function.
  • Library docstring examples and descriptions are expected to align with tests, please fix divergent tests and library docstrings.