Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/components/version.py: 61%
23 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-14 02:13 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import importlib
4import logging
5import daiquiri
6from daiquiri.core import marshal
7from daiquiri.core.components import Component, ComponentResource
8from daiquiri.core.schema.components import VersionSchema
11logger = logging.getLogger(__name__)
14class VersionResource(ComponentResource):
15 @marshal(out=[[200, VersionSchema(), "Current version information"]])
16 def get(self):
17 """Returns the current daiquiri version"""
18 return self._parent.get_versions()
21class Version(Component):
22 """Version Component
24 Simply returns the current app version
25 """
27 def setup(self):
28 self.register_route(VersionResource, "")
30 def get_versions(self):
31 versions = {"version": daiquiri.__version__, "libraries": {}}
33 for library in self._base_config["versions"]:
34 try:
35 mod = importlib.import_module(library)
36 versions["libraries"][library] = mod.__version__
37 except Exception:
38 logger.warning(f"Could not get version for library: {library}")
40 return versions