forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dagster registry generation and persist (airbytehq#25260)
* Define legacy and latest registry at same time * Fix file persist * Get persist to work * Expand generate models to all models * Add new registry types * Fix class name * Get valid registry type definition * Remove uuid hack * Fix ids for json schemas * Resolve issues * Update legacy assets * Add typed legacy registry * Fix icon issue * Regenerate models * Update spec mask to use registry type * Move v1 to v0 * Add json sanitized dict helper * Fix tests and format * Ensure we only get latest * Code review comments * fix missing spec error * Move registry code to helper
- Loading branch information
Showing
45 changed files
with
1,372 additions
and
207 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
airbyte-ci/connectors/metadata_service/lib/bin/generate-python-classes.sh
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,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|
||
YAML_DIR=metadata_service/models/src | ||
OUTPUT_DIR=metadata_service/models/generated | ||
|
||
# Ensure the yaml directory exists | ||
if [ ! -d "$YAML_DIR" ]; then | ||
echo "The yaml directory does not exist: $YAML_DIR" | ||
exit 1 | ||
fi | ||
|
||
|
||
rm -rf "$OUTPUT_DIR"/*.py | ||
mkdir -p "$OUTPUT_DIR" | ||
|
||
echo "# generated by generate-python-classes" > "$OUTPUT_DIR"/__init__.py | ||
|
||
for f in "$YAML_DIR"/*.yaml; do | ||
filename_wo_ext=$(basename "$f" | cut -d . -f 1) | ||
echo "from .$filename_wo_ext import *" >> "$OUTPUT_DIR"/__init__.py | ||
|
||
datamodel-codegen \ | ||
--input "$YAML_DIR/$filename_wo_ext.yaml" \ | ||
--output "$OUTPUT_DIR/$filename_wo_ext.py" \ | ||
--use-title-as-name \ | ||
--use-double-quotes \ | ||
--enum-field-as-literal all \ | ||
--disable-timestamp | ||
done |
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
54 changes: 54 additions & 0 deletions
54
...data_service/lib/metadata_service/models/generated/ActorDefinitionResourceRequirements.py
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,54 @@ | ||
# generated by datamodel-codegen: | ||
# filename: ActorDefinitionResourceRequirements.yaml | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel, Extra, Field | ||
from typing_extensions import Literal | ||
|
||
|
||
class ResourceRequirements(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
cpu_request: Optional[str] = None | ||
cpu_limit: Optional[str] = None | ||
memory_request: Optional[str] = None | ||
memory_limit: Optional[str] = None | ||
|
||
|
||
class JobType(BaseModel): | ||
__root__: Literal[ | ||
"get_spec", | ||
"check_connection", | ||
"discover_schema", | ||
"sync", | ||
"reset_connection", | ||
"connection_updater", | ||
"replicate", | ||
] = Field( | ||
..., | ||
description="enum that describes the different types of jobs that the platform runs.", | ||
title="JobType", | ||
) | ||
|
||
|
||
class JobTypeResourceLimit(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
jobType: JobType | ||
resourceRequirements: ResourceRequirements | ||
|
||
|
||
class ActorDefinitionResourceRequirements(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
default: Optional[ResourceRequirements] = Field( | ||
None, | ||
description="if set, these are the requirements that should be set for ALL jobs run for this actor definition.", | ||
) | ||
jobSpecific: Optional[List[JobTypeResourceLimit]] = None |
18 changes: 18 additions & 0 deletions
18
airbyte-ci/connectors/metadata_service/lib/metadata_service/models/generated/AllowedHosts.py
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,18 @@ | ||
# generated by datamodel-codegen: | ||
# filename: AllowedHosts.yaml | ||
|
||
from __future__ import annotations | ||
|
||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel, Extra, Field | ||
|
||
|
||
class AllowedHosts(BaseModel): | ||
class Config: | ||
extra = Extra.allow | ||
|
||
hosts: Optional[List[str]] = Field( | ||
None, | ||
description="An array of hosts that this connector can connect to. AllowedHosts not being present for the source or destination means that access to all hosts is allowed. An empty list here means that no network access is granted.", | ||
) |
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
131 changes: 131 additions & 0 deletions
131
...a_service/lib/metadata_service/models/generated/ConnectorRegistryDestinationDefinition.py
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,131 @@ | ||
# generated by datamodel-codegen: | ||
# filename: ConnectorRegistryDestinationDefinition.yaml | ||
|
||
from __future__ import annotations | ||
|
||
from datetime import date | ||
from typing import Any, Dict, List, Optional | ||
from uuid import UUID | ||
|
||
from pydantic import BaseModel, Extra, Field | ||
from typing_extensions import Literal | ||
|
||
|
||
class ReleaseStage(BaseModel): | ||
__root__: Literal["alpha", "beta", "generally_available", "custom"] = Field( | ||
..., | ||
description="enum that describes a connector's release stage", | ||
title="ReleaseStage", | ||
) | ||
|
||
|
||
class ResourceRequirements(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
cpu_request: Optional[str] = None | ||
cpu_limit: Optional[str] = None | ||
memory_request: Optional[str] = None | ||
memory_limit: Optional[str] = None | ||
|
||
|
||
class JobType(BaseModel): | ||
__root__: Literal[ | ||
"get_spec", | ||
"check_connection", | ||
"discover_schema", | ||
"sync", | ||
"reset_connection", | ||
"connection_updater", | ||
"replicate", | ||
] = Field( | ||
..., | ||
description="enum that describes the different types of jobs that the platform runs.", | ||
title="JobType", | ||
) | ||
|
||
|
||
class NormalizationDestinationDefinitionConfig(BaseModel): | ||
class Config: | ||
extra = Extra.allow | ||
|
||
normalizationRepository: str = Field( | ||
..., | ||
description="a field indicating the name of the repository to be used for normalization. If the value of the flag is NULL - normalization is not used.", | ||
) | ||
normalizationTag: str = Field( | ||
..., | ||
description="a field indicating the tag of the docker repository to be used for normalization.", | ||
) | ||
normalizationIntegrationType: str = Field( | ||
..., | ||
description="a field indicating the type of integration dialect to use for normalization.", | ||
) | ||
|
||
|
||
class AllowedHosts(BaseModel): | ||
class Config: | ||
extra = Extra.allow | ||
|
||
hosts: Optional[List[str]] = Field( | ||
None, | ||
description="An array of hosts that this connector can connect to. AllowedHosts not being present for the source or destination means that access to all hosts is allowed. An empty list here means that no network access is granted.", | ||
) | ||
|
||
|
||
class JobTypeResourceLimit(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
jobType: JobType | ||
resourceRequirements: ResourceRequirements | ||
|
||
|
||
class ActorDefinitionResourceRequirements(BaseModel): | ||
class Config: | ||
extra = Extra.forbid | ||
|
||
default: Optional[ResourceRequirements] = Field( | ||
None, | ||
description="if set, these are the requirements that should be set for ALL jobs run for this actor definition.", | ||
) | ||
jobSpecific: Optional[List[JobTypeResourceLimit]] = None | ||
|
||
|
||
class ConnectorRegistryDestinationDefinition(BaseModel): | ||
class Config: | ||
extra = Extra.allow | ||
|
||
destinationDefinitionId: UUID | ||
name: str | ||
dockerRepository: str | ||
dockerImageTag: str | ||
documentationUrl: str | ||
icon: Optional[str] = None | ||
spec: Dict[str, Any] | ||
tombstone: Optional[bool] = Field( | ||
False, | ||
description="if false, the configuration is active. if true, then this configuration is permanently off.", | ||
) | ||
public: Optional[bool] = Field( | ||
False, | ||
description="true if this connector definition is available to all workspaces", | ||
) | ||
custom: Optional[bool] = Field( | ||
False, description="whether this is a custom connector definition" | ||
) | ||
releaseStage: Optional[ReleaseStage] = None | ||
releaseDate: Optional[date] = Field( | ||
None, | ||
description="The date when this connector was first released, in yyyy-mm-dd format.", | ||
) | ||
resourceRequirements: Optional[ActorDefinitionResourceRequirements] = None | ||
protocolVersion: Optional[str] = Field( | ||
None, description="the Airbyte Protocol version supported by the connector" | ||
) | ||
normalizationConfig: Optional[NormalizationDestinationDefinitionConfig] = None | ||
supportsDbt: Optional[bool] = Field( | ||
None, | ||
description="an optional flag indicating whether DBT is used in the normalization. If the flag value is NULL - DBT is not used.", | ||
) | ||
allowedHosts: Optional[AllowedHosts] = None |
Oops, something went wrong.