Commit 0e7bc093 authored by Samuel GAIST's avatar Samuel GAIST

[databases] Add support for V2 version of the Database object

This will properly fetch all required protocol templates.
parent 96b7395b
Pipeline #47521 passed with stage
in 4 minutes and 36 seconds
...@@ -48,6 +48,7 @@ from beat.core import inputs ...@@ -48,6 +48,7 @@ from beat.core import inputs
from beat.core import utils from beat.core import utils
from beat.core.data import RemoteDataSource from beat.core.data import RemoteDataSource
from beat.core.database import Database from beat.core.database import Database
from beat.core.database import Storage
from beat.core.hash import hashDataset from beat.core.hash import hashDataset
from beat.core.hash import toPath from beat.core.hash import toPath
from beat.core.utils import NumpyJSONEncoder from beat.core.utils import NumpyJSONEncoder
...@@ -363,6 +364,7 @@ def pull_impl(webapi, prefix, names, force, indentation, format_cache): ...@@ -363,6 +364,7 @@ def pull_impl(webapi, prefix, names, force, indentation, format_cache):
""" """
from .dataformats import pull_impl as dataformats_pull from .dataformats import pull_impl as dataformats_pull
from .protocoltemplates import pull_impl as protocoltemplates_pull
status, names = common.pull( status, names = common.pull(
webapi, webapi,
...@@ -374,6 +376,22 @@ def pull_impl(webapi, prefix, names, force, indentation, format_cache): ...@@ -374,6 +376,22 @@ def pull_impl(webapi, prefix, names, force, indentation, format_cache):
indentation, indentation,
) )
# A database object cannot properly loaded if its protocol templates are
# missing, therefore, we must use lower level access.
protocol_templates = set()
for name in names:
db = Storage(prefix, name)
declaration, _, _ = db.load()
declaration = simplejson.loads(declaration)
version = declaration.get("schema_version", 1)
if version > 1:
for protocol in declaration["protocols"]:
protocol_templates.add(protocol["template"])
pt_status = protocoltemplates_pull(
webapi, prefix, protocol_templates, force, indentation + 2, format_cache
)
# see what dataformats one needs to pull # see what dataformats one needs to pull
dataformats = [] dataformats = []
for name in names: for name in names:
...@@ -385,7 +403,7 @@ def pull_impl(webapi, prefix, names, force, indentation, format_cache): ...@@ -385,7 +403,7 @@ def pull_impl(webapi, prefix, names, force, indentation, format_cache):
webapi, prefix, dataformats, force, indentation + 2, format_cache webapi, prefix, dataformats, force, indentation + 2, format_cache
) )
return status + df_status return status + df_status + pt_status
# ---------------------------------------------------------- # ----------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment