YiYiXu HF Staff commited on
Commit
73790f6
·
verified ·
1 Parent(s): 0299750

Update block.py

Browse files
Files changed (1) hide show
  1. block.py +14 -25
block.py CHANGED
@@ -11,28 +11,15 @@ from diffusers.modular_pipelines import (
11
 
12
  class MyCustomBlock(ModularPipelineBlocks):
13
  """
14
- A custom block for [describe what your block does].
15
-
16
- Replace this with your implementation.
17
  """
18
 
19
  @property
20
  def description(self) -> str:
21
  """Description of the block."""
22
- return "A template custom block - replace with your description"
 
23
 
24
-
25
- @property
26
- def expected_components(self) -> List[ComponentSpec]:
27
- """Define model components your block needs (e.g., transformers, VAEs)."""
28
- return [
29
- # Example:
30
- # ComponentSpec(
31
- # name="model",
32
- # type_hint=SomeModelClass,
33
- # repo="organization/model-name",
34
- # ),
35
- ]
36
 
37
  @property
38
  def inputs(self) -> List[InputParam]:
@@ -53,21 +40,23 @@ class MyCustomBlock(ModularPipelineBlocks):
53
  """Define output parameters for your block."""
54
  return [
55
  # Example:
56
- # OutputParam(
57
- # "result",
58
- # type_hint=str,
59
- # description="Output result",
60
- # metadata={"mellon": "text"}, # For Mellon UI
61
- # ),
62
  ]
63
 
64
  def __call__(self, components, state: PipelineState) -> PipelineState:
65
  """Execute your block logic."""
66
  block_state = self.get_block_state(state)
67
 
68
- # Your implementation here
69
- # Access inputs via block_state.<input_name>
70
- # Set outputs via block_state.<output_name> = value
 
 
71
 
72
  self.set_block_state(state, block_state)
73
  return components, state
 
11
 
12
  class MyCustomBlock(ModularPipelineBlocks):
13
  """
14
+ A custom block for inspect model info in your components manager
 
 
15
  """
16
 
17
  @property
18
  def description(self) -> str:
19
  """Description of the block."""
20
+ return "Inspect your components manager"
21
+
22
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  @property
25
  def inputs(self) -> List[InputParam]:
 
40
  """Define output parameters for your block."""
41
  return [
42
  # Example:
43
+ OutputParam(
44
+ "components_info",
45
+ type_hint=str,
46
+ description="model info in components manager ",
47
+ metadata={"mellon": "text"}, # For Mellon UI
48
+ ),
49
  ]
50
 
51
  def __call__(self, components, state: PipelineState) -> PipelineState:
52
  """Execute your block logic."""
53
  block_state = self.get_block_state(state)
54
 
55
+ try:
56
+ result = repr(components)
57
+ except Exception:
58
+ result = "not find"
59
+ block_state.components_info = result
60
 
61
  self.set_block_state(state, block_state)
62
  return components, state