Can we have collections of unbound generic Types


#1

I see that EvalMetricsResult has the field result: map<string, map<string, Timeseries>>, and Timeseries<V> is a generic type. Note that EvalMetricsResult is NOT a generic type.

However, I tried to define a type with a field that holds a list of unbound generic types (removing irrelevant fields):

type MachineLearningSerialPipeline<DI, DO> mixes MachineLearningPipe<DI, DO> {
  steps: [MachineLearningStep] schema suffix 'STEP'
}

where

type MachineLearningStep<DI, DO> {
...
}

is also a Generic Type.

MachineLearningSerialPipeline has a concrete parametrization:

entity type MachineLearningDatasetDatasetPipeline extends MachineLearningSerialPipeline<Dataset, Dataset> schema name 'MLPL'

and mixed in the Type:

abstract type MachineLearningPipe<DI, DO> {
... // a bunch of abstract functions, some taking DI and/or DO input Types
}

When I provision, I get the error message:

phoebuschen@Phoebuss-MacBook-Pro ~/c3/c3base (patch/DATA-1430-testonly-machineLearning) $ c3-prov tag -t machineLearning -g prod -a ~/c3/c3base
[machineLearning/prod] Created 57.52Mb ZIP of 15 packages in 4.1s
[machineLearning/prod] Server Errors: (2018-03-19T14:13:00.550-07:00)
{fileUrl:"meta://base/machineLearning/src/pipeline/MachineLearningDatasetDatasetPipeline.c3typ",lineNum:11,colNum:1,severity:"ERROR",message:"Reference field MachineLearningDatasetDatasetPipeline.steps is of parametric type MachineLearningStep.  All parameters for reference fields must be bound.",targetType:"MachineLearningDatasetDatasetPipeline"}
{fileUrl:"meta://base/machineLearning/src/pipeline/MachineLearningStep.c3typ",lineNum:17,colNum:1,severity:"ERROR",message:"Reference field MachineLearningStep.pipe is of parametric type MachineLearningPipe.  All parameters for reference fields must be bound.",targetType:"MachineLearningStep"}

I’m focused on the error message All parameters for reference fields must be bound.

I would guess that since C3’s DSL is not a compiled language, generics may not work the same since there is no type erasure. So perhaps the types have to be bound. But then why does EvalMetricsResult work without binding all parametrized Types? Why is my example different?


#2

I got some help narrowing down the problem, and it turns out the difference is that I have entity types in my examples, but EvalMetricsResult is not persistable type (no entity keyword). It turns out, persistable Types must have any parametrized Types bound.

I worked around this issue by making a non-generic base type that MachineLearningStep could extend. So,

type MachineLearningSerialPipeline<DI, DO> mixes MachineLearningPipe<DI, DO> {
  steps: [MachineLearningStepBase] schema suffix 'STEP'
}
extendable entity type MachineLearningStepBase schema name 'MLSB'

and

type MachineLearningStep<DI, DO> extends MachineLearningStepBase type key 'STP' {
... }