Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Python codegen for the OpenAPI backend #21316

Merged
merged 21 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix mypy
  • Loading branch information
grihabor committed Aug 17, 2024
commit 4d6eb01f3b7d7a548fe90bb5ab49b10362870690
6 changes: 1 addition & 5 deletions src/python/pants/backend/openapi/codegen/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

python_sources()

python_tests(
name="tests",
dependencies=[":lockfiles"],
timeout=600,
)
python_tests(name="tests", dependencies=[":lockfiles"])

resources(name="lockfiles", sources=["*.test.lock"])
20 changes: 11 additions & 9 deletions src/python/pants/backend/openapi/codegen/python/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from pants.backend.openapi.target_types import (
OpenApiDocumentDependenciesField,
OpenApiDocumentField,
OpenApiSourceField,
)
from pants.backend.openapi.util_rules.generator_process import OpenAPIGeneratorProcess
from pants.backend.python.dependency_inference.module_mapper import AllPythonTargets
Expand Down Expand Up @@ -58,6 +59,8 @@
HydrateSourcesRequest,
InferDependenciesRequest,
InferredDependencies,
TransitiveTargets,
TransitiveTargetsRequest,
)
from pants.engine.unions import UnionRule
from pants.source.source_root import SourceRoot, SourceRootRequest
Expand Down Expand Up @@ -168,17 +171,16 @@ async def generate_python_from_openapi(
if field_set.skip.value:
return GeneratedSources(EMPTY_SNAPSHOT)

(document_sources,) = await MultiGet(
(Get(HydratedSources, HydrateSourcesRequest(field_set.source)),)
# Get(TransitiveTargets, TransitiveTargetsRequest([field_set.address])),
(document_sources, transitive_targets) = await MultiGet(
Get(HydratedSources, HydrateSourcesRequest(field_set.source)),
Get(TransitiveTargets, TransitiveTargetsRequest([field_set.address])),
)

document_dependencies = []
# await MultiGet(
# Get(HydratedSources, HydrateSourcesRequest(tgt[OpenApiSourceField]))
# for tgt in transitive_targets.dependencies
# if tgt.has_field(OpenApiSourceField)
# )
document_dependencies = await MultiGet(
Get(HydratedSources, HydrateSourcesRequest(tgt[OpenApiSourceField]))
for tgt in transitive_targets.dependencies
if tgt.has_field(OpenApiSourceField)
)

input_digest = await Get(
Digest,
Expand Down
Loading