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 ql version in metadata #615

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
2 changes: 0 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
### New features

- Removed subscription API (#493)
- Replaced geocoder with [geopy](https://geopy.readthedocs.io/en/stable/) (#610)
- Bumped pillow from 8.4.0 to 9.0.0
c0c0n3 marked this conversation as resolved.
Show resolved Hide resolved

### Bug fixes

Expand Down
6 changes: 6 additions & 0 deletions src/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Most recent official release
__version_info__ = ('0', '8', '3')
__version__ = '.'.join(__version_info__)

# Current dev version for the next release
__dev_version__ = '0.9.0-dev'
3 changes: 2 additions & 1 deletion src/reporter/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from conftest import QL_BASE_URL
from _version import __dev_version__
import requests


Expand All @@ -7,5 +8,5 @@ def test_version():
r = requests.get('{}'.format(version_url))
assert r.status_code == 200, r.text
assert r.json() == {
"version": "0.9.0-dev"
"version": __dev_version__
}
4 changes: 2 additions & 2 deletions src/reporter/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from _version import __dev_version__

def version():
return {
'version': '0.9.0-dev'
'version': __dev_version__
}
4 changes: 3 additions & 1 deletion src/translators/sql_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from utils.common import iter_entity_attrs
from utils.jsondict import safe_get_value
from utils.maybe import maybe_map
from _version import __version__
import logging
from geocoding.slf import SlfQuery
import dateutil.parser
Expand Down Expand Up @@ -711,7 +712,8 @@ def _update_metadata_table(self, table_name, metadata):
# Attempt to re-create metadata table
self._create_metadata_table()
persisted_metadata = {}


metadata['ql_version'] = (__version__, "Text")
diff = metadata.keys() - persisted_metadata.keys()
if diff:
# we update using the difference to "not" corrupt the metadata
Expand Down
22 changes: 22 additions & 0 deletions src/translators/tests/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from translators.base_translator import BaseTranslator
from translators.sql_translator import NGSI_TEXT, NGSI_DATETIME, NGSI_STRUCTURED_VALUE
from utils.common import *
from src._version import __version__
from utils.tests.common import *
from datetime import datetime, timezone

Expand Down Expand Up @@ -774,3 +775,24 @@ def test_ngsi_ld(translator, ngsi_ld):
assert ngsi_ld['location']['value'] == loaded[0]['location']['values'][0]

translator.clean()

def expected_entity_attrs_meta_version():
return {
'entity_id': ['id', 'Text'],
'entity_type': ['type', 'Text'],
TIME_INDEX_NAME: ['time_index', 'DateTime'],
'ql_version': [__version__, 'Text'],
'a_number': ['a_number', 'Number'],
'an_integer': ['an_integer', 'Integer'],
'a_bool': ['a_bool', 'Boolean'],
'a_datetime': ['a_datetime', 'DateTime'],
'a_point': ['a_point', 'geo:point'],
'a_geom': ['a_geom', 'geo:json'],
'a_text': ['a_text', 'Text'],
'an_obj': ['an_obj', 'Custom'],
'an_array': ['an_array', 'StructuredValue']
}

def assert_entity_attrs_meta_version(translator, entity):
data = select_entity_attrs_meta_version(translator, entity)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this function come from? can you please check if this is something you need to push upstream? thanks :-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c0c0n3 I didn't find this function. I have updated the test file for version check.

assert data == expected_entity_attrs_meta_version()
2 changes: 2 additions & 0 deletions src/translators/tests/test_timescale_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pg8000
import pytest
import random
from _version import __version__
from time import sleep

from geocoding.geojson.wktcodec import decode_wkb_hexstr
Expand Down Expand Up @@ -105,6 +106,7 @@ def expected_entity_attrs_meta():
'entity_id': ['id', 'Text'],
'entity_type': ['type', 'Text'],
TIME_INDEX_NAME: ['time_index', 'DateTime'],
'ql_version': [__version__, 'Text'],
'a_number': ['a_number', 'Number'],
'an_integer': ['an_integer', 'Integer'],
'a_bool': ['a_bool', 'Boolean'],
Expand Down