MCPcopy Create free account
hub / github.com/StackStorm/st2 / generate_api_spec_via_fmt

Function generate_api_spec_via_fmt

pants-plugins/api_spec/rules.py:67–111  ·  view source on GitHub ↗
(
    request: GenerateAPISpecViaFmtTargetsRequest.Batch,
    subsystem: GenerateApiSpec,
)

Source from the content-addressed store, hash-verified

65 level=LogLevel.DEBUG,
66)
67async def generate_api_spec_via_fmt(
68 request: GenerateAPISpecViaFmtTargetsRequest.Batch,
69 subsystem: GenerateApiSpec,
70) -> FmtResult:
71 config_files_get = Get(ConfigFiles, ConfigFilesRequest, subsystem.config_request())
72
73 # We use a pex to actually generate the api spec with an external script.
74 # Generation cannot be inlined here because it needs to import the st2 code.
75 # (the script location is defined on the GenerateApiSpec subsystem)
76 pex_get = Get(VenvPex, PexFromTargetsRequest, subsystem.pex_request())
77
78 config_files, pex = await MultiGet(config_files_get, pex_get)
79
80 input_digest = await Get(
81 Digest,
82 MergeDigests((config_files.snapshot.digest, request.snapshot.digest)),
83 )
84
85 result = await Get(
86 ProcessResult,
87 VenvPexProcess(
88 pex,
89 argv=(
90 "--config-file",
91 subsystem.config_file,
92 ),
93 input_digest=input_digest,
94 description="Regenerating openapi.yaml api spec",
95 level=LogLevel.DEBUG,
96 ),
97 )
98
99 contents = [FileContent(file, result.stdout) for file in request.files]
100
101 output_digest = await Get(Digest, CreateDigest(contents))
102 output_snapshot = await Get(Snapshot, Digest, output_digest)
103
104 return FmtResult(
105 input=request.snapshot,
106 output=output_snapshot,
107 # Drop result.stdout since we already wrote it to a file
108 stdout="",
109 stderr=strip_v2_chroot_path(result.stderr),
110 tool_name=request.tool_name,
111 )
112
113
114@rule(

Callers

nothing calls this directly

Calls 2

config_requestMethod · 0.80
pex_requestMethod · 0.45

Tested by

no test coverage detected