Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version checker for correct cb version #190 #200

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#### v0.2.5
#### v0.2.6
- fixed inconsistency of `entity_type` as required argument ([#188](https://github.com/RWTH-EBC/FiLiP/issues/188))
- add warning if ``Orion`` version is not supported ([#200](https://github.com/RWTH-EBC/FiLiP/issues/200))

#### v0.2.5
- fixed service group edition not working ([#170](https://github.com/RWTH-EBC/FiLiP/issues/170))
Expand Down
17 changes: 17 additions & 0 deletions filip/clients/ngsi_v2/cb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PositiveFloat, \
AnyHttpUrl
from typing import Any, Dict, List , Optional, TYPE_CHECKING, Union
from packaging import version
import re
import requests
from urllib.parse import urljoin
Expand Down Expand Up @@ -74,6 +75,8 @@ def __init__(self,
fiware_header=fiware_header,
**kwargs)

self._check_correct_cb_version()

def __pagination(self,
*,
method: PaginationMethod = PaginationMethod.GET,
Expand Down Expand Up @@ -157,6 +160,20 @@ def get_version(self) -> Dict:
self.logger.error(err)
raise

def _check_correct_cb_version(self) -> None:
"""
Checks whether the used Orion version is greater or equal than the minimum required orion version of
the current filip version
"""
orion_version = self.get_version()['orion']['version']
if version.parse(orion_version) < version.parse(settings.minimum_orion_version):
warnings.warn(
f"You are using orion version {orion_version}. There was a breaking change in Orion Version "
f"{settings.minimum_orion_version}, therefore functionality is not assured when using "
f"version {orion_version}."
)


def get_resources(self) -> Dict:
"""
Gets reo
Expand Down
1 change: 1 addition & 0 deletions filip/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Settings(BaseSettings):
QL_URL: AnyHttpUrl = Field(default="http://127.0.0.1:8668",
env=['QUANTUMLEAP_URL', 'QL_URL'])

minimum_orion_version: str = '3.6.0'
class Config:
env_file = '.env.filip'
env_file_encoding = 'utf-8'
Expand Down