From 2d2e8a63fbcf81a37bbfe234064474364b3b96cd Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 16 Mar 2020 15:38:41 +0100 Subject: [PATCH] add new argument in config.new() --- tiramisu/api.py | 8 +++++--- tiramisu/config.py | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tiramisu/api.py b/tiramisu/api.py index a6e5dd1..366d689 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -1533,7 +1533,8 @@ class _TiramisuContextMixConfig(_TiramisuContextGroupConfig, _TiramisuContextCon async def new(self, session_id, storage=None, - type='config'): + type='config', + new=None): """Create and add a new config""" config = self._config_bag.context if storage is None: @@ -1543,9 +1544,10 @@ class _TiramisuContextMixConfig(_TiramisuContextGroupConfig, _TiramisuContextCon new_config = await config.new_config(connection, session_id=session_id, storage=storage, - type_=type) + type_=type, + new=new) return await self._return_config(new_config, - new_config._storage) + storage) async def pop(self, session_id=None, diff --git a/tiramisu/config.py b/tiramisu/config.py index 83421d4..8a8ed0d 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -1175,12 +1175,15 @@ class KernelMixConfig(KernelGroupConfig): connection, session_id, type_='config', - storage=None): - if session_id in [child.impl_getname() for child in self._impl_children]: + storage=None, + new=None, + ): + if new is None: + new = session_id not in await list_sessions() + if new and session_id in [child.impl_getname() for child in self._impl_children]: raise ConflictError(_('config name must be uniq in ' 'groupconfig for {0}').format(session_id)) assert type_ in ('config', 'metaconfig', 'mixconfig'), _('unknown type {}').format(type_) - new = session_id not in await list_sessions() if type_ == 'config': config = await KernelConfig(self._impl_descr, session_id=session_id,