-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate schema for pipeline.yaml and config.yaml (#70)
- Loading branch information
Showing
32 changed files
with
1,812 additions
and
744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ runs: | |
- name: Install python and set up Poetry | ||
uses: bakdata/ci-templates/actions/[email protected] | ||
with: | ||
poetry-version: "1.3.2" | ||
python-version: "3.10" | ||
|
||
- name: Update documentation branch with mike | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
types: [opened, ready_for_review, synchronize] | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, ready_for_review, synchronize] | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
|
@@ -20,8 +20,9 @@ jobs: | |
- uses: actions/checkout@v3 | ||
|
||
- name: Install python and set up Poetry | ||
uses: bakdata/ci-templates/actions/[email protected].2 | ||
uses: bakdata/ci-templates/actions/[email protected].3 | ||
with: | ||
poetry-version: "1.3.2" | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
|
||
- name: Bump version | ||
id: bump_version | ||
uses: bakdata/ci-templates/actions/[email protected].2 | ||
uses: bakdata/ci-templates/actions/[email protected].3 | ||
with: | ||
release-type: "patch" | ||
|
||
|
@@ -40,7 +40,9 @@ jobs: | |
shell: bash | ||
|
||
- name: Release to TestPyPI | ||
uses: bakdata/ci-templates/actions/[email protected].2 | ||
uses: bakdata/ci-templates/actions/[email protected].3 | ||
with: | ||
python-version: "3.10" | ||
poetry-version: "1.3.2" | ||
publish-to-test: true | ||
pypi-token: ${{ secrets.test-pypi-token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from pathlib import Path | ||
from typing import Annotated, Any, Sequence | ||
|
||
from pydantic import Field, schema, schema_json_of | ||
from pydantic.fields import ModelField | ||
from pydantic.schema import SkipField | ||
|
||
from kpops.cli.pipeline_config import PipelineConfig | ||
from kpops.components.base_components.kafka_app import KafkaApp | ||
from kpops.components.base_components.kafka_connect import ( | ||
KafkaSinkConnector, | ||
KafkaSourceConnector, | ||
) | ||
from kpops.components.base_components.kubernetes_app import KubernetesApp | ||
from kpops.components.streams_bootstrap.producer.producer_app import ProducerApp | ||
from kpops.components.streams_bootstrap.streams.streams_app import StreamsApp | ||
|
||
|
||
def write(contents: str, path: Path) -> None: | ||
with open(path, "w") as f: | ||
print(contents, file=f) | ||
|
||
|
||
original_field_schema = schema.field_schema | ||
|
||
|
||
# adapted from https://github.com/tiangolo/fastapi/issues/1378#issuecomment-764966955 | ||
def field_schema(field: ModelField, **kwargs: Any) -> Any: | ||
if field.field_info.extra.get("hidden_from_schema"): | ||
raise SkipField(f"{field.name} field is being hidden") | ||
else: | ||
return original_field_schema(field, **kwargs) | ||
|
||
|
||
schema.field_schema = field_schema | ||
|
||
PipelineComponent = ( | ||
KubernetesApp | ||
| KafkaApp | ||
| StreamsApp | ||
| ProducerApp | ||
| KafkaSourceConnector | ||
| KafkaSinkConnector | ||
) | ||
|
||
|
||
AnnotatedPipelineComponent = Annotated[ | ||
PipelineComponent, Field(discriminator="schema_type") | ||
] | ||
|
||
|
||
schema = schema_json_of( | ||
Sequence[AnnotatedPipelineComponent], | ||
title="kpops pipeline schema", | ||
by_alias=True, | ||
indent=4, | ||
).replace("schema_type", "type") | ||
write(schema, Path("schema_pipeline.json")) | ||
|
||
schema = schema_json_of(PipelineConfig, title="kpops config schema", indent=4) | ||
write(schema, Path("schema_config.json")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.