Skip to content

Commit

Permalink
metadata-service[lib]: introduce a rolloutConfiguration field to th…
Browse files Browse the repository at this point in the history
…e metadata model (#44504)

## What
Closes airbytehq/airbyte-internal-issues#9249

## How
* Add a `RolloutConfiguration.yaml` model
* Reference it in the connector metadata model under the `releases` field.
* Introduce a `isReleaseCandidate` field in under `releases`
* Re-generated pydantic models
  • Loading branch information
alafanechere authored Aug 22, 2024
1 parent 367f706 commit f58652b
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import AnyUrl, BaseModel, Extra, Field, constr
from pydantic import AnyUrl, BaseModel, Extra, Field, conint, constr
from typing_extensions import Literal


Expand Down Expand Up @@ -96,6 +96,21 @@ class JobType(BaseModel):
)


class RolloutConfiguration(BaseModel):
class Config:
extra = Extra.forbid

initialPercentage: Optional[conint(ge=0, le=100)] = Field(
0, description="The percentage of users that should receive the new version initially."
)
maxPercentage: Optional[conint(ge=0, le=100)] = Field(
50, description="The percentage of users who should receive the release candidate during the test phase before full rollout."
)
advanceDelayMinutes: Optional[conint(ge=10)] = Field(
10, description="The number of minutes to wait before advancing the rollout percentage."
)


class StreamBreakingChangeScope(BaseModel):
class Config:
extra = Extra.forbid
Expand Down Expand Up @@ -268,6 +283,8 @@ class ConnectorReleases(BaseModel):
class Config:
extra = Extra.forbid

isReleaseCandidate: Optional[bool] = Field(False, description="Whether the release is eligible to be a release candidate.")
rolloutConfiguration: Optional[RolloutConfiguration] = None
breakingChanges: ConnectorBreakingChanges
migrationDocumentationUrl: Optional[AnyUrl] = Field(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import AnyUrl, BaseModel, Extra, Field, constr
from pydantic import AnyUrl, BaseModel, Extra, Field, conint, constr
from typing_extensions import Literal


Expand Down Expand Up @@ -63,6 +63,21 @@ class Config:
)


class RolloutConfiguration(BaseModel):
class Config:
extra = Extra.forbid

initialPercentage: Optional[conint(ge=0, le=100)] = Field(
0, description="The percentage of users that should receive the new version initially."
)
maxPercentage: Optional[conint(ge=0, le=100)] = Field(
50, description="The percentage of users who should receive the release candidate during the test phase before full rollout."
)
advanceDelayMinutes: Optional[conint(ge=10)] = Field(
10, description="The number of minutes to wait before advancing the rollout percentage."
)


class StreamBreakingChangeScope(BaseModel):
class Config:
extra = Extra.forbid
Expand Down Expand Up @@ -175,6 +190,8 @@ class ConnectorReleases(BaseModel):
class Config:
extra = Extra.forbid

isReleaseCandidate: Optional[bool] = Field(False, description="Whether the release is eligible to be a release candidate.")
rolloutConfiguration: Optional[RolloutConfiguration] = None
breakingChanges: ConnectorBreakingChanges
migrationDocumentationUrl: Optional[AnyUrl] = Field(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import AnyUrl, BaseModel, Extra, Field, constr
from pydantic import AnyUrl, BaseModel, Extra, Field, conint, constr
from typing_extensions import Literal


Expand Down Expand Up @@ -59,6 +59,21 @@ class Config:
)


class RolloutConfiguration(BaseModel):
class Config:
extra = Extra.forbid

initialPercentage: Optional[conint(ge=0, le=100)] = Field(
0, description="The percentage of users that should receive the new version initially."
)
maxPercentage: Optional[conint(ge=0, le=100)] = Field(
50, description="The percentage of users who should receive the release candidate during the test phase before full rollout."
)
advanceDelayMinutes: Optional[conint(ge=10)] = Field(
10, description="The number of minutes to wait before advancing the rollout percentage."
)


class StreamBreakingChangeScope(BaseModel):
class Config:
extra = Extra.forbid
Expand Down Expand Up @@ -171,6 +186,8 @@ class ConnectorReleases(BaseModel):
class Config:
extra = Extra.forbid

isReleaseCandidate: Optional[bool] = Field(False, description="Whether the release is eligible to be a release candidate.")
rolloutConfiguration: Optional[RolloutConfiguration] = None
breakingChanges: ConnectorBreakingChanges
migrationDocumentationUrl: Optional[AnyUrl] = Field(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Any, Dict, List, Optional, Union
from uuid import UUID

from pydantic import AnyUrl, BaseModel, Extra, Field, constr
from pydantic import AnyUrl, BaseModel, Extra, Field, conint, constr
from typing_extensions import Literal


Expand Down Expand Up @@ -63,6 +63,21 @@ class Config:
)


class RolloutConfiguration(BaseModel):
class Config:
extra = Extra.forbid

initialPercentage: Optional[conint(ge=0, le=100)] = Field(
0, description="The percentage of users that should receive the new version initially."
)
maxPercentage: Optional[conint(ge=0, le=100)] = Field(
50, description="The percentage of users who should receive the release candidate during the test phase before full rollout."
)
advanceDelayMinutes: Optional[conint(ge=10)] = Field(
10, description="The number of minutes to wait before advancing the rollout percentage."
)


class StreamBreakingChangeScope(BaseModel):
class Config:
extra = Extra.forbid
Expand Down Expand Up @@ -185,6 +200,8 @@ class ConnectorReleases(BaseModel):
class Config:
extra = Extra.forbid

isReleaseCandidate: Optional[bool] = Field(False, description="Whether the release is eligible to be a release candidate.")
rolloutConfiguration: Optional[RolloutConfiguration] = None
breakingChanges: ConnectorBreakingChanges
migrationDocumentationUrl: Optional[AnyUrl] = Field(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,22 @@
from datetime import date
from typing import Any, Dict, List, Optional

from pydantic import AnyUrl, BaseModel, Extra, Field, constr
from pydantic import AnyUrl, BaseModel, Extra, Field, conint, constr


class RolloutConfiguration(BaseModel):
class Config:
extra = Extra.forbid

initialPercentage: Optional[conint(ge=0, le=100)] = Field(
0, description="The percentage of users that should receive the new version initially."
)
maxPercentage: Optional[conint(ge=0, le=100)] = Field(
50, description="The percentage of users who should receive the release candidate during the test phase before full rollout."
)
advanceDelayMinutes: Optional[conint(ge=10)] = Field(
10, description="The number of minutes to wait before advancing the rollout percentage."
)


class StreamBreakingChangeScope(BaseModel):
Expand Down Expand Up @@ -51,6 +66,8 @@ class ConnectorReleases(BaseModel):
class Config:
extra = Extra.forbid

isReleaseCandidate: Optional[bool] = Field(False, description="Whether the release is eligible to be a release candidate.")
rolloutConfiguration: Optional[RolloutConfiguration] = None
breakingChanges: ConnectorBreakingChanges
migrationDocumentationUrl: Optional[AnyUrl] = Field(
None,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# generated by datamodel-codegen:
# filename: RolloutConfiguration.yaml

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Extra, Field, conint


class RolloutConfiguration(BaseModel):
class Config:
extra = Extra.forbid

initialPercentage: Optional[conint(ge=0, le=100)] = Field(
0, description="The percentage of users that should receive the new version initially."
)
maxPercentage: Optional[conint(ge=0, le=100)] = Field(
50, description="The percentage of users who should receive the release candidate during the test phase before full rollout."
)
advanceDelayMinutes: Optional[conint(ge=10)] = Field(
10, description="The number of minutes to wait before advancing the rollout percentage."
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from .ReleaseStage import *
from .RemoteRegistries import *
from .ResourceRequirements import *
from .RolloutConfiguration import *
from .Secret import *
from .SecretStore import *
from .SourceFileInfo import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ additionalProperties: false
required:
- breakingChanges
properties:
isReleaseCandidate:
description: Whether the release is eligible to be a release candidate.
type: boolean
default: false
rolloutConfiguration:
$ref: RolloutConfiguration.yaml
breakingChanges:
$ref: "#/definitions/ConnectorBreakingChanges"
migrationDocumentationUrl:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
"$schema": http://json-schema.org/draft-07/schema#
"$id": https://github.com/airbytehq/airbyte/airbyte-ci/connectors/metadata_service/lib/metadata_service/models/src/RolloutConfiguration.yaml
title: RolloutConfiguration
description: configuration for the rollout of a connector
type: object
additionalProperties: false
properties:
initialPercentage:
type: integer
minimum: 0
maximum: 100
default: 0
description: The percentage of users that should receive the new version initially.
maxPercentage:
type: integer
minimum: 0
maximum: 100
default: 50
description: The percentage of users who should receive the release candidate during the test phase before full rollout.
advanceDelayMinutes:
type: integer
minimum: 10
default: 10
description: The number of minutes to wait before advancing the rollout percentage.
2 changes: 1 addition & 1 deletion airbyte-ci/connectors/metadata_service/lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metadata-service"
version = "0.10.3"
version = "0.11.0"
description = ""
authors = ["Ben Church <ben@airbyte.io>"]
readme = "README.md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def have_same_keys(dict1, dict2, omitted_keys=None):
def test_transform_to_json_does_not_mutate_keys(valid_metadata_upload_files, valid_metadata_yaml_files):
all_valid_metadata_files = valid_metadata_upload_files + valid_metadata_yaml_files

fields_with_defaults = ["data.supportsRefreshes"]
fields_with_defaults = ["data.supportsRefreshes", "data.releases.isReleaseCandidate"]

for file_path in all_valid_metadata_files:
metadata_file_path = pathlib.Path(file_path)
Expand Down

0 comments on commit f58652b

Please sign in to comment.