File tree Expand file tree Collapse file tree 6 files changed +57
-29
lines changed Expand file tree Collapse file tree 6 files changed +57
-29
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ Please use [this](https://docs.gitlab.com/ee/development/changelog.html) documen
77### Fixed
88
99* ci: Removed ` black 21.12b0 ` dependency since bug in ` datamodel-codegen-generator ` is fixed.
10- * config: Verify ` advanced.scheduler ` config for correctness unsupported features.
10+ * cli: Fixed ` config export ` command crash when ` advanced.reindex ` dictionary is present.
11+ * cli: Removed optionals from ` config export ` output so the result can be loaded again.
12+ * config: Verify ` advanced.scheduler ` config for the correctness and unsupported features.
1113* context: Fixed ignored ` wait ` argument of ` fire_hook ` method.
1214* hasura: Fixed processing relation fields with missing ` related_name ` .
1315* jobs: Fixed default ` apscheduler ` config.
Original file line number Diff line number Diff line change 4949from dipdup .enums import SkipHistory
5050from dipdup .exceptions import ConfigInitializationException
5151from dipdup .exceptions import ConfigurationError
52+ from dipdup .utils import exclude_none
5253from dipdup .utils import import_from
5354from dipdup .utils import pascal_to_snake
5455from dipdup .utils import snake_to_pascal
@@ -1072,10 +1073,12 @@ def load(
10721073
10731074 def dump (self ) -> str :
10741075 config_json = json .dumps (self , default = pydantic_encoder )
1076+ config_yaml = yaml .safe_load (config_json )
1077+
10751078 return cast (
10761079 str ,
10771080 yaml .dump (
1078- yaml . safe_load ( config_json ),
1081+ exclude_none ( config_yaml ),
10791082 indent = 2 ,
10801083 default_flow_style = False ,
10811084 ),
Original file line number Diff line number Diff line change @@ -35,9 +35,11 @@ class IndexStatus(Enum):
3535 SYNCING = 'SYNCING'
3636 REALTIME = 'REALTIME'
3737 ROLLBACK = 'ROLLBACK'
38+ # TODO: Drop in 5.0.0
3839 ONESHOT = 'ONESHOT'
3940
4041
42+ # TODO: Drop in 5.0.0
4143class ReindexingReason (ReversedEnum ):
4244 MANUAL = 'triggered manually from callback'
4345 MIGRATION = 'applied migration requires reindexing'
@@ -48,7 +50,8 @@ class ReindexingReason(ReversedEnum):
4850 MISSING_INDEX_TEMPLATE = 'index template is missing, can\' t restore index state'
4951
5052
51- class ReindexingReasonC (Enum ):
53+ # NOTE: Used as a key in config, must inherit from str
54+ class ReindexingReasonC (str , Enum ):
5255 manual = 'manual'
5356 migration = 'migration'
5457 rollback = 'rollback'
Original file line number Diff line number Diff line change @@ -177,3 +177,11 @@ def skip_ci(fn):
177177 if os .environ .get ('CI' ):
178178 return skip ('CI environment, skipping' )(fn )
179179 return fn
180+
181+
182+ def exclude_none (config_json ):
183+ if isinstance (config_json , (list , tuple )):
184+ return [exclude_none (i ) for i in config_json if i is not None ]
185+ if isinstance (config_json , dict ):
186+ return {k : exclude_none (v ) for k , v in config_json .items () if v is not None }
187+ return config_json
Original file line number Diff line number Diff line change 1+ import tempfile
12from os .path import dirname
23from os .path import join
34from typing import Callable
@@ -34,3 +35,14 @@ async def test_validators(self):
3435 ContractConfig (address = 'lalalalalalalalalalalalalalalalalala' )
3536 with self .assertRaises (ConfigurationError ):
3637 TzktDatasourceConfig (kind = 'tzkt' , url = 'not_an_url' )
38+
39+ async def test_dump (self ):
40+ config = DipDupConfig .load ([self .path ])
41+ config .initialize ()
42+
43+ tmp = tempfile .mkstemp ()[1 ]
44+ with open (tmp , 'w' ) as f :
45+ f .write (config .dump ())
46+
47+ config = DipDupConfig .load ([tmp ], environment = False )
48+ config .initialize ()
You can’t perform that action at this time.
0 commit comments