Skip to content

Commit d909759

Browse files
committed
Minor changes
1 parent 0c015ce commit d909759

File tree

6 files changed

+26
-27
lines changed

6 files changed

+26
-27
lines changed

backend/infrahub/generators/models.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
from __future__ import annotations
2+
13
from typing import Optional
24

35
from pydantic import BaseModel, ConfigDict, Field
46

5-
from infrahub.message_bus.types import ProposedChangeGeneratorDefinition
6-
77

88
class RequestGeneratorRun(BaseModel):
99
"""Runs a generator."""
@@ -30,3 +30,16 @@ class RequestGeneratorDefinitionRun(BaseModel):
3030

3131
generator_definition: ProposedChangeGeneratorDefinition = Field(..., description="The Generator Definition")
3232
branch: str = Field(..., description="The branch to target")
33+
34+
35+
class ProposedChangeGeneratorDefinition(BaseModel):
36+
definition_id: str
37+
definition_name: str
38+
query_name: str
39+
convert_query_response: bool
40+
query_models: list[str]
41+
repository_id: str
42+
class_name: str
43+
file_path: str
44+
parameters: dict
45+
group_id: str

backend/infrahub/generators/tasks.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
from infrahub import lock
1010
from infrahub.core.constants import GeneratorInstanceStatus, InfrahubKind
11-
from infrahub.generators.models import RequestGeneratorDefinitionRun, RequestGeneratorRun
11+
from infrahub.generators.models import (
12+
ProposedChangeGeneratorDefinition,
13+
RequestGeneratorDefinitionRun,
14+
RequestGeneratorRun,
15+
)
1216
from infrahub.git.base import extract_repo_file_information
1317
from infrahub.git.repository import get_initialized_repo
14-
from infrahub.message_bus.types import ProposedChangeGeneratorDefinition
1518
from infrahub.services import InfrahubServices, services
1619
from infrahub.workflows.catalogue import REQUEST_GENERATOR_DEFINITION_RUN, REQUEST_GENERATOR_RUN
1720

@@ -136,17 +139,12 @@ async def run_generator_definition(branch: str) -> None:
136139

137140

138141
@flow(name="request_generator_definition_run")
139-
async def request_generator_definition_run(model: RequestGeneratorDefinitionRun, service: InfrahubServices) -> None:
142+
async def request_generator_definition_run(model: RequestGeneratorDefinitionRun) -> None:
143+
service = services.service
140144
async with service.task_report(
141145
title="Executing Generator",
142146
related_node=model.generator_definition.definition_id,
143147
) as task_report:
144-
service.log.info(
145-
"Received request to run generator",
146-
branch=model.branch,
147-
generator_definition=model.generator_definition.definition_id,
148-
)
149-
150148
group = await service.client.get(
151149
kind=InfrahubKind.GENERICGROUP,
152150
prefetch_relationships=True,

backend/infrahub/message_bus/messages/check_generator_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from pydantic import Field
44

5+
from infrahub.generators.models import ProposedChangeGeneratorDefinition
56
from infrahub.message_bus import InfrahubMessage
6-
from infrahub.message_bus.types import ProposedChangeGeneratorDefinition
77

88

99
class CheckGeneratorRun(InfrahubMessage):

backend/infrahub/message_bus/messages/request_generatordefinition_check.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from pydantic import ConfigDict, Field
22

3+
from infrahub.generators.models import ProposedChangeGeneratorDefinition
34
from infrahub.message_bus import InfrahubMessage
4-
from infrahub.message_bus.types import ProposedChangeBranchDiff, ProposedChangeGeneratorDefinition
5+
from infrahub.message_bus.types import ProposedChangeBranchDiff
56

67

78
class RequestGeneratorDefinitionCheck(InfrahubMessage):

backend/infrahub/message_bus/operations/requests/proposed_change.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
from infrahub.core.validators.checker import schema_validators_checker
2323
from infrahub.core.validators.determiner import ConstraintValidatorDeterminer
2424
from infrahub.dependencies.registry import get_component_registry
25+
from infrahub.generators.models import ProposedChangeGeneratorDefinition
2526
from infrahub.git.repository import InfrahubRepository, get_initialized_repo
2627
from infrahub.log import get_logger
2728
from infrahub.message_bus import InfrahubMessage, messages
2829
from infrahub.message_bus.types import (
2930
ProposedChangeArtifactDefinition,
3031
ProposedChangeBranchDiff,
31-
ProposedChangeGeneratorDefinition,
3232
ProposedChangeRepository,
3333
ProposedChangeSubscriber,
3434
)

backend/infrahub/message_bus/types.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,6 @@ def transform_location(self) -> str:
107107
raise ValueError("Invalid kind for Transform")
108108

109109

110-
class ProposedChangeGeneratorDefinition(BaseModel):
111-
definition_id: str
112-
definition_name: str
113-
query_name: str
114-
convert_query_response: bool
115-
query_models: list[str]
116-
repository_id: str
117-
class_name: str
118-
file_path: str
119-
parameters: dict
120-
group_id: str
121-
122-
123110
class ProposedChangeBranchDiff(BaseModel):
124111
diff_summary: list[NodeDiff] = Field(default_factory=list, description="The DiffSummary between two branches")
125112
repositories: list[ProposedChangeRepository] = Field(default_factory=list)

0 commit comments

Comments
 (0)