Commit 634738d0 authored by Bruno Duyé's avatar Bruno Duyé

Fix #414: missing dimension in some cases

parent de03b940
Pipeline #55082 canceled with stage
in 3 minutes and 32 seconds
......@@ -179,22 +179,17 @@ def iterate_dataset(filepath):
def get_dimensions_by_roles(dataset):
"""Find and return dimensions, grouped by role:
- time dimension
- metric dimension
- other dimensions, in the same order than in dataset.dimensions()
"""
time_dimension = None
metric_dimension = None
other_dimensions = []
for dimension in dataset.dimensions():
if dimension.role == 'time':
time_dimension = dimension
elif dimension.role == 'metric':
metric_dimension = dimension
else:
other_dimensions.append(dimension)
assert time_dimension, "didn't found time dimension in dataset !"
assert metric_dimension, "didn't found metric dimension in dataset !"
return time_dimension, metric_dimension, other_dimensions
return time_dimension, other_dimensions
def get_series_observations(dataframe):
"""Return values corresponding to given series_dimensions_values, on a array, to be added to dataset's series.jsonl file
......@@ -210,7 +205,7 @@ def iterate_dataset(filepath):
"""
dimensions_values_labels = {}
for dimension in dataset.dimensions():
if dimension.role in ('time', 'metric'):
if dimension.role == 'time':
continue
dimension_values = []
for value_n in range(0, len(dimension)):
......@@ -272,10 +267,10 @@ def iterate_dataset(filepath):
assert len(collection) == 1, "Error: more than one dataset found" # a json file should only contain one dataset
dataset = collection.dataset(0)
# Separate dimensions by roles
time_dimension, metric_dimension, other_dimensions = get_dimensions_by_roles(dataset)
time_dimension, other_dimensions = get_dimensions_by_roles(dataset)
other_dimensions_codes = list(dimension.did for dimension in other_dimensions)
log.debug("time dimension: {!r} - metric dimension: {!r} - \"real\" dimensions: {!r}".format(time_dimension.label,
metric_dimension.label, other_dimensions_codes))
log.debug(
"time dimension: {!r}: - \"real\" dimensions: {!r}".format(time_dimension.label, other_dimensions_codes))
# Get dataset values as Pandas dataframe, with dimensions codes as columns names
dataframe = dataset.to_data_frame(content='id')
except Exception as e:
......
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