Commit 3506c9dc authored by Mitar's avatar Mitar
Browse files

Updating to new metadata changes.

parent 9311ed8a
Pipeline #54402301 failed with stage
in 4 minutes and 40 seconds
......@@ -94,8 +94,8 @@ class IncrementPrimitive(transformer.TransformerPrimitiveBase[Inputs, Outputs, H
# Metadata might not be preserved through operations, so we make sure and update metadata ourselves.
# Because just values changed (but not structure) and the primitive is a transformation, we can reuse
# inputs metadata, but just update the value reference.
outputs.metadata = inputs.metadata.set_for_value(outputs)
# inputs metadata, but generate new metadata for new value to assure everything is matching.
outputs.metadata = inputs.metadata.generate(outputs)
# Wrap it into default "CallResult" object: we are not doing any iterations.
return base.CallResult(outputs)
......
......@@ -91,14 +91,9 @@ class MonomialPrimitive(supervised_learning.SupervisedLearnerPrimitiveBase[Input
result = (self._a * input + self.hyperparams['bias'] for input in inputs)
# We convert a regular list to container list which supports metadata attribute.
outputs: container.List = container.List(result)
# Even if the structure of outputs is the same as inputs, conceptually, outputs
# are different, they are new data. So we do not reuse metadata from inputs but create
# new metadata. We do this by clearing old metadata which keeps history and link the
# to inputs metadata. "for_value" tells that this new metadata will be associated with
# "outputs".
outputs.metadata = inputs.metadata.clear(for_value=outputs)
# Even if the structure of outputs is the same as inputs, conceptually, outputs are different,
# they are new data. So we do not reuse metadata from inputs but generate new metadata.
outputs: container.List = container.List(result, generate_metadata=True)
# Wrap it into default "CallResult" object: we are not doing any iterations.
return base.CallResult(outputs)
......
......@@ -119,7 +119,9 @@ class PrimitiveSumPrimitive(transformer.TransformerPrimitiveBase[Inputs, Outputs
if not results:
raise exceptions.InvalidArgumentValueError("No primitives provided as hyper-parameters.")
outputs = container.List([sum(x) for x in zip(*[result.value for result in results])])
# Even if the structure of outputs is the same as inputs, conceptually, outputs are different,
# they are new data. So we do not reuse metadata from inputs but generate new metadata.
outputs = container.List([sum(x) for x in zip(*[result.value for result in results])], generate_metadata=True)
# We return the maximum number of iterations done by any produce method we called.
iterations_done = None
......@@ -130,13 +132,6 @@ class PrimitiveSumPrimitive(transformer.TransformerPrimitiveBase[Inputs, Outputs
else:
iterations_done = max(iterations_done, result.iterations_done)
# Even if the structure of outputs is the same as inputs, conceptually, outputs
# are different, they are new data. So we do not reuse metadata from inputs but create
# new metadata. We do this by clearing old metadata which keeps history and link the
# to inputs metadata. "for_value" tells that this new metadata will be associated with
# "outputs".
outputs.metadata = inputs.metadata.clear(for_value=outputs)
return base.CallResult(
value=outputs,
has_finished=all(result.has_finished for result in results),
......
......@@ -92,15 +92,9 @@ class RandomPrimitive(generator.GeneratorPrimitiveBase[Outputs, None, Hyperparam
# TODO: Optimize this if the inputs are a sequence of integers, we could reuse the state.
results = [numpy.random.RandomState(self.random_seed).normal(self.hyperparams['mu'], self.hyperparams['sigma'], i + 1)[-1] for i in inputs]
# Outputs are different from inputs, so we do not reuse metadata from inputs but create new metadata.
# We convert the list to a container DataFrame which supports metadata attribute.
# We do not generate metadata automatically here because we will to it in the next step.
outputs = container.DataFrame({'results': results}, generate_metadata=False)
# Outputs are different from inputs, so we do not reuse metadata from inputs but create
# new metadata. We do this by clearing old metadata which keeps history and link the
# to inputs metadata. "for_value" tells that this new metadata will be associated with
# "outputs".
outputs.metadata = inputs.metadata.clear(for_value=outputs, generate_metadata=True)
outputs = container.DataFrame({'results': results}, generate_metadata=True)
# Wrap it into default "CallResult" object: we are not doing any iterations.
return base.CallResult(outputs)
......
......@@ -144,13 +144,8 @@ class SumPrimitive(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperpa
result = float(response.read())
outputs = container.List((result,))
# Outputs are different from inputs, so we do not reuse metadata from inputs but create
# new metadata. We do this by clearing old metadata which keeps history and link the
# to inputs metadata. "for_value" tells that this new metadata will be associated with
# "outputs".
outputs.metadata = inputs.metadata.clear(for_value=outputs)
# Outputs are different from inputs, so we do not reuse metadata from inputs but generate new metadata.
outputs = container.List((result,), generate_metadata=True)
# Wrap it into default "CallResult" object: we are not doing any iterations.
return base.CallResult(outputs)
......
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