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

Bump dependencies of packages. Migrating from Pydantic v1 to v2 #98

Merged
merged 8 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,34 @@ oddrn_gen = PostgresqlGenerator(
schemas='schema_name', databases='database_name', tables='table_name'
)

oddrn_gen.base_oddrn
print(oddrn_gen.base_oddrn)
# //postgresql/host/my.host.com:5432
oddrn_gen.available_paths
print(oddrn_gen.available_paths)
# ('databases', 'schemas', 'tables', 'views', 'tables_columns', 'views_columns', 'relationships')

oddrn_gen.get_data_source_oddrn()
print(oddrn_gen.get_data_source_oddrn())
# //postgresql/host/my.host.com:5432/databases/database_name

oddrn_gen.get_oddrn_by_path("schemas")
print(oddrn_gen.get_oddrn_by_path("schemas"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name

oddrn_gen.get_oddrn_by_path("databases")
print(oddrn_gen.get_oddrn_by_path("databases"))
# //postgresql/host/my.host.com:5432/databases/database_name

oddrn_gen.get_oddrn_by_path("tables")
print(oddrn_gen.get_oddrn_by_path("tables"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/table_name

# you can set or change path:
oddrn_gen.set_oddrn_paths(tables="another_table_name", tables_columns="new_column_name")
oddrn_gen.get_oddrn_by_path("tables_columns")
print(oddrn_gen.get_oddrn_by_path("tables_columns"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/new_column_name

oddrn_gen.set_oddrn_paths(relationships="references_table_2_with_constraint_fk")
print(oddrn_gen.get_oddrn_by_path("relationships"))
# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/relationships/references_table_2_with_constraint_fk

# you can get path wih new values:
oddrn_gen.get_oddrn_by_path("tables_columns", new_value="another_new_column_name")
print(oddrn_gen.get_oddrn_by_path("tables_columns", new_value="another_new_column_name"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need print here?

# //postgresql/host/my.host.com:5432/databases/database_name/schemas/schema_name/tables/another_table_name/columns/another_new_column_name


Expand All @@ -130,25 +131,25 @@ oddrn_gen = GlueGenerator(
jobs='job_name', runs='run_name', owners='owner_name'
)

oddrn_gen.available_paths
print(oddrn_gen.available_paths)
# ('databases', 'tables', 'columns', 'owners', 'jobs', 'runs')

oddrn_gen.get_oddrn_by_path("databases")
print(oddrn_gen.get_oddrn_by_path("databases"))
# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name

oddrn_gen.get_oddrn_by_path("tables")
print(oddrn_gen.get_oddrn_by_path("tables"))
# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name/tables/table_name'

oddrn_gen.get_oddrn_by_path("columns")
print(oddrn_gen.get_oddrn_by_path("columns"))
# //glue/cloud/aws/account/acc_id/region/reg_id/databases/database_name/tables/table_name/columns/column_name

oddrn_gen.get_oddrn_by_path("jobs")
print(oddrn_gen.get_oddrn_by_path("jobs"))
# //glue/cloud/aws/account/acc_id/region/reg_id/jobs/job_name

oddrn_gen.get_oddrn_by_path("runs")
print(oddrn_gen.get_oddrn_by_path("runs"))
# //glue/cloud/aws/account/acc_id/region/reg_id/jobs/job_name/runs/run_name

oddrn_gen.get_oddrn_by_path("owners")
print(oddrn_gen.get_oddrn_by_path("owners"))
# //glue/cloud/aws/account/acc_id/region/reg_id/owners/owner_name

```
Expand Down
18 changes: 9 additions & 9 deletions oddrn_generator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from oddrn_generator.generators import (
AirbyteGenerator,
AirflowGenerator,
ApiGenerator,
AthenaGenerator,
AzureBlobStorageGenerator,
AzureDataFactoryGenerator,
AzureSQLGenerator,
BigQueryStorageGenerator,
BigTableGenerator,
CassandraGenerator,
CKANGenerator,
ClickHouseGenerator,
CouchbaseGenerator,
CubeJsGenerator,
Expand All @@ -12,11 +18,13 @@
DatabricksUnityCatalogGenerator,
DbtGenerator,
DmsGenerator,
DuckDBGenerator,
DynamodbGenerator,
ElasticSearchGenerator,
FeastGenerator,
FilesystemGenerator,
FivetranGenerator,
GCSGenerator,
Generator,
GlueGenerator,
GreatExpectationsGenerator,
Expand All @@ -43,6 +51,7 @@
S3CustomGenerator,
S3Generator,
SagemakerGenerator,
ScyllaDBGenerator,
SingleStoreGenerator,
SnowflakeGenerator,
SQLiteGenerator,
Expand All @@ -51,15 +60,6 @@
TarantoolGenerator,
TrinoGenerator,
VerticaGenerator,
BigTableGenerator,
DuckDBGenerator,
ScyllaDBGenerator,
GCSGenerator,
AzureBlobStorageGenerator,
BigQueryStorageGenerator,
CKANGenerator,
AzureDataFactoryGenerator,
ApiGenerator,
)

__all__ = [
Expand Down
45 changes: 24 additions & 21 deletions oddrn_generator/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
from oddrn_generator.path_models import (
AirbytePathsModel,
AirflowPathsModel,
ApiPathsModel,
AthenaPathsModel,
AzureDataFactoryPathsModel,
AzureSQLPathsModel,
BasePathsModel,
BigQueryStoragePathsModel,
BigTablePathsModel,
BlobPathsModel,
CassandraPathsModel,
CKANPathsModel,
ClickHousePathsModel,
CouchbasePathsModel,
CubeJsPathModel,
Expand Down Expand Up @@ -56,18 +61,13 @@
TableauPathsModel,
TarantoolPathsModel,
VerticaPathsModel,
BlobPathsModel,
BigQueryStoragePathsModel,
CKANPathsModel,
AzureDataFactoryPathsModel,
ApiPathsModel,
)
from oddrn_generator.server_models import (
AbstractServerModel,
AWSCloudModel,
BlobStorageCloudModel,
AzureDomainCloudModel,
AzureCloudSettings,
AzureDomainCloudModel,
BlobStorageCloudModel,
CloudSettings,
GCPCloudModel,
GoogleCloudSettings,
Expand All @@ -79,8 +79,7 @@
ServerModelConfig,
SQLiteModel,
)

from .utils import escape
from oddrn_generator.utils import escape


def parse_url(url: str) -> dict:
Expand Down Expand Up @@ -121,16 +120,20 @@ def __init__(
):
config = ServerModelConfig(
cloud_settings=CloudSettings(**cloud_settings) if cloud_settings else None,
azure_cloud_settings=AzureCloudSettings(**azure_cloud_settings)
if azure_cloud_settings
else None,
azure_cloud_settings=(
AzureCloudSettings(**azure_cloud_settings)
if azure_cloud_settings
else None
),
host_settings=HostSettings(host=host_settings) if host_settings else None,
s3_custom_cloud_settings=S3CustomSettings(endpoint=endpoint)
if endpoint
else None,
google_cloud_settings=GoogleCloudSettings(**google_cloud_settings)
if google_cloud_settings
else None,
s3_custom_cloud_settings=(
S3CustomSettings(endpoint=endpoint) if endpoint else None
),
google_cloud_settings=(
GoogleCloudSettings(**google_cloud_settings)
if google_cloud_settings
else None
),
)

self.server_obj: AbstractServerModel = self.server_model.create(config)
Expand All @@ -149,15 +152,15 @@ def base_oddrn(self) -> str:

@property
def available_paths(self) -> tuple:
return tuple(self.paths_obj.__config__.dependencies_map.keys())
return tuple(self.paths_obj.dependencies_map.keys())

def get_oddrn_by_path(self, path: str, new_value: str = None) -> str:
dependency = self.paths_obj.get_dependency(path)
if new_value:
self.paths_obj.set_path_value(path, new_value)
else:
self.paths_obj.check_if_path_is_set(path)
paths_dict = self.paths_obj.dict(
paths_dict = self.paths_obj.model_dump(
include=set(dependency), exclude_none=True, by_alias=True
)
return (
Expand All @@ -167,7 +170,7 @@ def get_oddrn_by_path(self, path: str, new_value: str = None) -> str:
def set_oddrn_paths(self, **new_paths) -> None:
old_paths = {
k: v
for k, v in self.paths_obj.dict(exclude_none=True).items()
for k, v in self.paths_obj.model_dump(exclude_none=True).items()
if k not in list(new_paths.keys())
}

Expand Down
Loading
Loading