base.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (C) 2025 AIDC-AI
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. """
  13. Pipeline UI Base & Registry
  14. Defines the PipelineUI protocol and the registration mechanism.
  15. """
  16. from typing import Dict, Any, List, Type
  17. class PipelineUI:
  18. """
  19. Base class for Pipeline UI plugins.
  20. Each pipeline should implement a subclass to define its own full-page UI.
  21. """
  22. name: str = "base"
  23. display_name: str = "Base Pipeline"
  24. icon: str = "🔌"
  25. description: str = ""
  26. def render(self, pixelle_video: Any):
  27. """
  28. Render the full page content for this pipeline (below settings).
  29. Args:
  30. pixelle_video: The initialized PixelleVideoCore instance.
  31. """
  32. raise NotImplementedError
  33. # ==================== Registry ====================
  34. _pipeline_uis: Dict[str, PipelineUI] = {}
  35. def register_pipeline_ui(ui_class: Type[PipelineUI]):
  36. """Register a pipeline UI class"""
  37. instance = ui_class()
  38. _pipeline_uis[instance.name] = instance
  39. def get_pipeline_ui(name: str) -> PipelineUI:
  40. """Get a pipeline UI instance by name"""
  41. return _pipeline_uis.get(name)
  42. def get_all_pipeline_uis() -> List[PipelineUI]:
  43. """Get all registered pipeline UI instances"""
  44. return list(_pipeline_uis.values())