port-ocean 0.1.3rc2__py3-none-any.whl → 0.1.3rc4__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
@@ -62,6 +62,9 @@ def decamelize_object(obj: Any) -> Any:
62
62
  def parse_config(
63
63
  config: dict[str, Any], existing_data: dict[str, Any]
64
64
  ) -> dict[str, Any]:
65
+ """
66
+ Normalizing the config yaml file to work with snake_case and getting only the data that is missing for the settings
67
+ """
65
68
  for key, value in config.items():
66
69
  decamelize_key = decamelize(key)
67
70
  if isinstance(value, dict):
@@ -69,7 +72,10 @@ def parse_config(
69
72
  value, existing_data.get(decamelize_key, {})
70
73
  )
71
74
  elif isinstance(value, str):
75
+ # If the value is a provider, we try to load it from the provider
72
76
  if provider_match := re.match(PROVIDER_WRAPPER_PATTERN, value):
77
+ # If the there is already value for that field, we ignore it
78
+ # If the provider failed to load, we ignore it
73
79
  if decamelize_key not in existing_data:
74
80
  try:
75
81
  existing_data[decamelize_key] = load_from_config_provider(
@@ -1,7 +1,9 @@
1
+ import json
1
2
  from typing import Type, Any, Optional
2
3
 
3
4
  from humps import decamelize
4
- from pydantic import BaseModel, AnyUrl, create_model, Extra, parse_obj_as
5
+ from pydantic import BaseModel, AnyUrl, create_model, Extra, parse_obj_as, validator
6
+ from pydantic.fields import ModelField
5
7
 
6
8
 
7
9
  class Configuration(BaseModel, extra=Extra.allow):
@@ -11,6 +13,18 @@ class Configuration(BaseModel, extra=Extra.allow):
11
13
  default: Optional[Any]
12
14
 
13
15
 
16
+ def dynamic_parse(value: Any, field: ModelField) -> Any:
17
+ should_json_load = issubclass(field.annotation, dict) or issubclass(
18
+ field.annotation, list
19
+ )
20
+ if isinstance(value, str) and should_json_load:
21
+ try:
22
+ return json.loads(value)
23
+ except json.JSONDecodeError:
24
+ pass
25
+ return value
26
+
27
+
14
28
  def default_config_factory(configurations: Any) -> Type[BaseModel]:
15
29
  configurations = parse_obj_as(list[Configuration], configurations)
16
30
  fields: dict[str, tuple[Any, Any]] = {}
@@ -40,4 +54,9 @@ def default_config_factory(configurations: Any) -> Type[BaseModel]:
40
54
  default,
41
55
  )
42
56
 
43
- return create_model("Config", **fields) # type: ignore
57
+ dynamic_model = create_model( # type: ignore
58
+ __model_name="Config",
59
+ **fields,
60
+ __validators__={"dynamic_parse": validator("*", pre=True)(dynamic_parse)},
61
+ )
62
+ return dynamic_model
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: port-ocean
3
- Version: 0.1.3rc2
3
+ Version: 0.1.3rc4
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,8 +36,8 @@ port_ocean/clients/port/mixins/integrations.py,sha256=wbK3EXqPv5pRZytQjIVKwDa2aL
36
36
  port_ocean/clients/port/types.py,sha256=NnT1W2H_tZ_9cyEFoDhb90q3apf8p9emkHYspbPoZJQ,593
37
37
  port_ocean/clients/port/utils.py,sha256=jgF0Gq8lZA9qkpsHlzPTuKoAdY6AlvF1Bl5JB4SnQGE,781
38
38
  port_ocean/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- port_ocean/config/base.py,sha256=D26b8kduqp0pR9SLFliB8y7bkKQhwEqn5nXXh06WAJU,3665
40
- port_ocean/config/dynamic.py,sha256=TrDF7MM52UX6nBuDvD6ClXhcBgfz0_bxWDLjB26HenQ,1259
39
+ port_ocean/config/base.py,sha256=ppibshn1EnCe2Mv_81-t5ZeGcF6tANPUlpMgLvTtngU,4019
40
+ port_ocean/config/dynamic.py,sha256=CIRDnqFUPSnNMLZ-emRCMVAjEQNBlIujhZ7OGwi_aKs,1816
41
41
  port_ocean/config/settings.py,sha256=Ghg71GJgeIPzFMyvAanErfCMCVDbc-roDGkdtgtTYf8,1231
42
42
  port_ocean/consumers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  port_ocean/consumers/base_consumer.py,sha256=L0gW0DvUpeGVdb1RH83-wgbI37V6fsUKfd9Yox42-Gs,125
@@ -93,8 +93,8 @@ port_ocean/port_defaults.py,sha256=QzrO_7Q0hRX-bgMpm-6XTedMbTZQH73NfHby3l1FEDw,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.1.3rc2.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
97
- port_ocean-0.1.3rc2.dist-info/METADATA,sha256=pY0iV6-ZpaSR7XhAOHR3IAaPHa_0zkCW_aMVyBdN3vY,6359
98
- port_ocean-0.1.3rc2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
99
- port_ocean-0.1.3rc2.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
100
- port_ocean-0.1.3rc2.dist-info/RECORD,,
96
+ port_ocean-0.1.3rc4.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
97
+ port_ocean-0.1.3rc4.dist-info/METADATA,sha256=XYm51wAD0X5ERWxcVsYemoSJnFfEg1YHs6YDD60t5S0,6359
98
+ port_ocean-0.1.3rc4.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
99
+ port_ocean-0.1.3rc4.dist-info/entry_points.txt,sha256=F_DNUmGZU2Kme-8NsWM5LLE8piGMafYZygRYhOVtcjA,54
100
+ port_ocean-0.1.3rc4.dist-info/RECORD,,