port-ocean 0.2.0.dev2__py3-none-any.whl → 0.2.2.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of port-ocean might be problematic. Click here for more details.

port_ocean/config/base.py CHANGED
@@ -1,12 +1,14 @@
1
1
  import os
2
2
  import re
3
3
  from pathlib import Path
4
+ from types import GenericAlias
4
5
  from typing import Any
5
6
 
6
7
  import yaml
7
8
  from humps import decamelize
8
9
  from pydantic import BaseSettings
9
10
  from pydantic.env_settings import EnvSettingsSource, InitSettingsSource
11
+ from pydantic.main import ModelMetaclass, BaseModel
10
12
 
11
13
  PROVIDER_WRAPPER_PATTERN = r"{{ from (.*) }}"
12
14
  PROVIDER_CONFIG_PATTERN = r"^[a-zA-Z0-9]+ .*$"
@@ -60,17 +62,30 @@ def decamelize_object(obj: Any) -> Any:
60
62
 
61
63
 
62
64
  def parse_config(
63
- config: dict[str, Any], existing_data: dict[str, Any]
65
+ settings_model: BaseModel | ModelMetaclass,
66
+ config: dict[str, Any],
67
+ existing_data: dict[str, Any],
64
68
  ) -> dict[str, Any]:
65
69
  """
66
70
  Normalizing the config yaml file to work with snake_case and getting only the data that is missing for the settings
67
71
  """
68
72
  for key, value in config.items():
69
73
  decamelize_key = decamelize(key)
70
- if isinstance(value, dict):
74
+ if isinstance(value, dict) and settings_model is not None:
75
+ # If the value is ModelMetaClass typed then its a nested model, and we need to parse it
76
+ # If the value is a primitive dict then we need to decamelize the keys and not recurse into the values because its no longer part of the model
77
+ _type = settings_model.__annotations__[decamelize_key]
78
+ is_primitive_dict_type = _type is dict or (
79
+ isinstance(_type, GenericAlias) and _type.__origin__ is dict
80
+ )
81
+
82
+ if is_primitive_dict_type:
83
+ _type = None
84
+
71
85
  existing_data[decamelize_key] = parse_config(
72
- value, existing_data.get(decamelize_key, {})
86
+ _type, value, existing_data.get(decamelize_key, {})
73
87
  )
88
+
74
89
  elif isinstance(value, str):
75
90
  # If the value is a provider, we try to load it from the provider
76
91
  if provider_match := re.match(PROVIDER_WRAPPER_PATTERN, value):
@@ -95,7 +110,7 @@ def load_providers(
95
110
  ) -> dict[str, Any]:
96
111
  yaml_content = read_yaml_config_settings_source(settings, base_path)
97
112
  data = yaml.safe_load(yaml_content)
98
- return parse_config(data, existing_values)
113
+ return parse_config(settings, data, existing_values)
99
114
 
100
115
 
101
116
  class BaseOceanSettings(BaseSettings):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.2.0.dev2
3
+ Version: 0.2.2.dev1
4
4
  Summary: Port Ocean is a CLI tool for managing your Port projects.
5
5
  Home-page: https://app.getport.io
6
6
  Keywords: ocean,port-ocean,port
@@ -36,7 +36,7 @@ port_ocean/clients/port/mixins/integrations.py,sha256=lKsZHIrfDpAFlPy1X1sXj7eQ6U
36
36
  port_ocean/clients/port/types.py,sha256=NnT1W2H_tZ_9cyEFoDhb90q3apf8p9emkHYspbPoZJQ,593
37
37
  port_ocean/clients/port/utils.py,sha256=T2poQv_8sCs59pIIeynJWe9NZi6pAO0SHhS7KLErnIs,789
38
38
  port_ocean/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- port_ocean/config/base.py,sha256=nqHIZJZK3IyR48cOQGKQaQv4kz5IG_oUhrP9dJScC-U,4011
39
+ port_ocean/config/base.py,sha256=BHx7bsqoD3zK2g9ARuZxe0FPx-VcLkpdI_MKavLkPUM,4735
40
40
  port_ocean/config/dynamic.py,sha256=CIRDnqFUPSnNMLZ-emRCMVAjEQNBlIujhZ7OGwi_aKs,1816
41
41
  port_ocean/config/settings.py,sha256=2QmMrKpAZ3dHVbo-nCoo-GiHFXWwUV1FddKcDWSrjW8,1230
42
42
  port_ocean/consumers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -93,8 +93,8 @@ port_ocean/port_defaults.py,sha256=slubEiM4SJKCzD4bHzf8Rwj3RgsHZXZuYZ0ouhcIQOA,7
93
93
  port_ocean/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
94
  port_ocean/run.py,sha256=Bd6c6qYqQZlZqTLyRWRIkf579NQNqrr-o4mVAnBIISA,2834
95
95
  port_ocean/utils.py,sha256=2a30qmGMSPgsTxfpz2RiI3xDsM0-TkaKAbvJBaYqvCc,1007
96
- port_ocean-0.2.0.dev2.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
97
- port_ocean-0.2.0.dev2.dist-info/METADATA,sha256=JI46-sPH25MozELzcP7aMgPUeSpPwh38qHfusoUulFQ,6361
98
- port_ocean-0.2.0.dev2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
99
- port_ocean-0.2.0.dev2.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
100
- port_ocean-0.2.0.dev2.dist-info/RECORD,,
96
+ port_ocean-0.2.2.dev1.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
97
+ port_ocean-0.2.2.dev1.dist-info/METADATA,sha256=-WGpPZQK05oxsgS4F17uTK5Zeq0NkW0spwPaTFj01OQ,6361
98
+ port_ocean-0.2.2.dev1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
99
+ port_ocean-0.2.2.dev1.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
100
+ port_ocean-0.2.2.dev1.dist-info/RECORD,,