From 267fe63ad5f67f2c205072bbc3b45b956d404731 Mon Sep 17 00:00:00 2001 From: Alexandre Maurel Date: Tue, 30 Jan 2024 14:38:10 +0100 Subject: [PATCH] OperatorSpec added from stage --- tercen/model/base.py | 254 +++++++++++++------------------------ tercen/model/impl.py | 16 +-- tercen/model/vocabulary.py | 14 +- 3 files changed, 94 insertions(+), 190 deletions(-) diff --git a/tercen/model/base.py b/tercen/model/base.py index 795bc15..d102b63 100644 --- a/tercen/model/base.py +++ b/tercen/model/base.py @@ -280,12 +280,10 @@ def createFromJson(cls, m): return impl.MeltStepModel(m) if kind == Vocabulary.ExportModel_CLASS: return impl.ExportModel(m) - if kind == Vocabulary.MappingFactor_CLASS: - return impl.MappingFactor(m) - if kind == Vocabulary.MetaFactor_CLASS: - return impl.MetaFactor(m) if kind == Vocabulary.Attribute_CLASS: return impl.Attribute(m) + if kind == Vocabulary.MappingFactor_CLASS: + return impl.MappingFactor(m) if kind == Vocabulary.ChartLine_CLASS: return impl.ChartLine(m) if kind == Vocabulary.ChartPoint_CLASS: @@ -1505,41 +1503,6 @@ def toJson(self): return m -class OperatorOutputSpecBase(BaseObject): - def __init__(self, m=None): - import tercen.model.impl as impl - if m is not None: - self.fromJson(m) - - else: - super().__init__(m) - - def fromJson(self, m): - import tercen.model.impl as impl - super().fromJson(m) - self.subKind = m.get(Vocabulary.SUBKIND) - if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.OperatorOutputSpec_CLASS: - self.subKind = m.get(Vocabulary.KIND) - - @classmethod - def createFromJson(cls, m): - import tercen.model.impl as impl - kind = m.get(Vocabulary.KIND) - if kind == Vocabulary.OperatorOutputSpec_CLASS: - return impl.OperatorOutputSpec(m) - raise ValueError("bad kind : " + kind + - " for class OperatorOutputSpec in createFromJson") - - def toJson(self): - m = super().toJson() - m[Vocabulary.KIND] = Vocabulary.OperatorOutputSpec_CLASS - if self.subKind is not None and self.subKind != Vocabulary.OperatorOutputSpec_CLASS: - m[Vocabulary.SUBKIND] = self.subKind - else: - m.pop(Vocabulary.SUBKIND, None) - return m - - class ResourceSummaryBase(BaseObject): def __init__(self, m=None): import tercen.model.impl as impl @@ -2822,7 +2785,6 @@ def __init__(self, m=None): if m is None: super().__init__(m) self.properties = list() - self.operatorSpec = impl.OperatorSpec() else: self.fromJson(m) @@ -2839,11 +2801,6 @@ def fromJson(self, m): self.properties = list() for o in m.get(Vocabulary.properties_OP): self.properties.append(PropertyBase.createFromJson(o)) - if m.get(Vocabulary.operatorSpec_OP) is None: - self.operatorSpec = impl.OperatorSpec() - else: - self.operatorSpec = OperatorSpecBase.createFromJson( - m.get(Vocabulary.operatorSpec_OP)) @classmethod def createFromJson(cls, m): @@ -2875,7 +2832,6 @@ def toJson(self): m.pop(Vocabulary.SUBKIND, None) m[Vocabulary.properties_OP] = list( map(lambda x: x.toJson(), self.properties)) - m[Vocabulary.operatorSpec_OP] = self.operatorSpec if self.operatorSpec is None else self.operatorSpec.toJson() return m @@ -5329,79 +5285,33 @@ def toJson(self): return m -class FactorBase(BaseObject): - def __init__(self, m=None): - import tercen.model.impl as impl - FactorBase.__bases__ = (impl.SciObject,) - if m is None: - super().__init__(m) - self.name = "" - self.type = "" - else: - self.fromJson(m) - - def fromJson(self, m): - import tercen.model.impl as impl - FactorBase.__bases__ = (impl.SciObject,) - super().fromJson(m) - self.subKind = m.get(Vocabulary.SUBKIND) - if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.Factor_CLASS: - self.subKind = m.get(Vocabulary.KIND) - self.name = m[Vocabulary.name_DP] - self.type = m[Vocabulary.type_DP] - - @classmethod - def createFromJson(cls, m): - import tercen.model.impl as impl - kind = m.get(Vocabulary.KIND) - if kind == Vocabulary.Factor_CLASS: - return impl.Factor(m) - if kind == Vocabulary.MappingFactor_CLASS: - return impl.MappingFactor(m) - if kind == Vocabulary.MetaFactor_CLASS: - return impl.MetaFactor(m) - if kind == Vocabulary.Attribute_CLASS: - return impl.Attribute(m) - raise ValueError("bad kind : " + kind + - " for class Factor in createFromJson") - - def toJson(self): - m = super().toJson() - m[Vocabulary.KIND] = Vocabulary.Factor_CLASS - if self.subKind is not None and self.subKind != Vocabulary.Factor_CLASS: - m[Vocabulary.SUBKIND] = self.subKind - else: - m.pop(Vocabulary.SUBKIND, None) - m[Vocabulary.name_DP] = self.name - m[Vocabulary.type_DP] = self.type - return m - - class MetaFactorBase(BaseObject): def __init__(self, m=None): import tercen.model.impl as impl - MetaFactorBase.__bases__ = (impl.Factor,) if m is None: super().__init__(m) + self.name = "" self.description = "" - self.ontologyMapping = "" self.crosstabMapping = "" - self.cardinality = "" + self.metaCardinality = "" + self.type = "" + self.ontologyMapping = "" self.factors = list() else: self.fromJson(m) def fromJson(self, m): import tercen.model.impl as impl - MetaFactorBase.__bases__ = (impl.Factor,) super().fromJson(m) self.subKind = m.get(Vocabulary.SUBKIND) if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.MetaFactor_CLASS: self.subKind = m.get(Vocabulary.KIND) + self.name = m[Vocabulary.name_DP] self.description = m[Vocabulary.description_DP] - self.ontologyMapping = m[Vocabulary.ontologyMapping_DP] self.crosstabMapping = m[Vocabulary.crosstabMapping_DP] - self.cardinality = m[Vocabulary.cardinality_DP] + self.metaCardinality = m[Vocabulary.metaCardinality_DP] + self.type = m[Vocabulary.type_DP] + self.ontologyMapping = m[Vocabulary.ontologyMapping_DP] if m.get(Vocabulary.factors_OP) is None: self.factors = list() else: @@ -5415,8 +5325,6 @@ def createFromJson(cls, m): kind = m.get(Vocabulary.KIND) if kind == Vocabulary.MetaFactor_CLASS: return impl.MetaFactor(m) - if kind == Vocabulary.MappingFactor_CLASS: - return impl.MappingFactor(m) raise ValueError("bad kind : " + kind + " for class MetaFactor in createFromJson") @@ -5427,10 +5335,12 @@ def toJson(self): m[Vocabulary.SUBKIND] = self.subKind else: m.pop(Vocabulary.SUBKIND, None) + m[Vocabulary.name_DP] = self.name m[Vocabulary.description_DP] = self.description - m[Vocabulary.ontologyMapping_DP] = self.ontologyMapping m[Vocabulary.crosstabMapping_DP] = self.crosstabMapping - m[Vocabulary.cardinality_DP] = self.cardinality + m[Vocabulary.metaCardinality_DP] = self.metaCardinality + m[Vocabulary.type_DP] = self.type + m[Vocabulary.ontologyMapping_DP] = self.ontologyMapping m[Vocabulary.factors_OP] = list( map(lambda x: x.toJson(), self.factors)) return m @@ -6123,6 +6033,52 @@ def toJson(self): return m +class FactorBase(BaseObject): + def __init__(self, m=None): + import tercen.model.impl as impl + FactorBase.__bases__ = (impl.SciObject,) + if m is None: + super().__init__(m) + self.name = "" + self.type = "" + else: + self.fromJson(m) + + def fromJson(self, m): + import tercen.model.impl as impl + FactorBase.__bases__ = (impl.SciObject,) + super().fromJson(m) + self.subKind = m.get(Vocabulary.SUBKIND) + if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.Factor_CLASS: + self.subKind = m.get(Vocabulary.KIND) + self.name = m[Vocabulary.name_DP] + self.type = m[Vocabulary.type_DP] + + @classmethod + def createFromJson(cls, m): + import tercen.model.impl as impl + kind = m.get(Vocabulary.KIND) + if kind == Vocabulary.Factor_CLASS: + return impl.Factor(m) + if kind == Vocabulary.Attribute_CLASS: + return impl.Attribute(m) + if kind == Vocabulary.MappingFactor_CLASS: + return impl.MappingFactor(m) + raise ValueError("bad kind : " + kind + + " for class Factor in createFromJson") + + def toJson(self): + m = super().toJson() + m[Vocabulary.KIND] = Vocabulary.Factor_CLASS + if self.subKind is not None and self.subKind != Vocabulary.Factor_CLASS: + m[Vocabulary.SUBKIND] = self.subKind + else: + m.pop(Vocabulary.SUBKIND, None) + m[Vocabulary.name_DP] = self.name + m[Vocabulary.type_DP] = self.type + return m + + class AttributeBase(BaseObject): def __init__(self, m=None): import tercen.model.impl as impl @@ -6541,10 +6497,8 @@ def __init__(self, m=None): import tercen.model.impl as impl if m is None: super().__init__(m) - self.ontologyUri = "" self.ontologyVersion = "" - self.inputSpecs = list() - self.outputSpecs = list() + self.crosstabSpecs = list() else: self.fromJson(m) @@ -6554,21 +6508,13 @@ def fromJson(self, m): self.subKind = m.get(Vocabulary.SUBKIND) if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.OperatorSpec_CLASS: self.subKind = m.get(Vocabulary.KIND) - self.ontologyUri = m[Vocabulary.ontologyUri_DP] self.ontologyVersion = m[Vocabulary.ontologyVersion_DP] - if m.get(Vocabulary.inputSpecs_OP) is None: - self.inputSpecs = list() + if m.get(Vocabulary.crosstabSpecs_OP) is None: + self.crosstabSpecs = list() else: - self.inputSpecs = list() - for o in m.get(Vocabulary.inputSpecs_OP): - self.inputSpecs.append(OperatorInputSpecBase.createFromJson(o)) - if m.get(Vocabulary.outputSpecs_OP) is None: - self.outputSpecs = list() - else: - self.outputSpecs = list() - for o in m.get(Vocabulary.outputSpecs_OP): - self.outputSpecs.append( - OperatorOutputSpecBase.createFromJson(o)) + self.crosstabSpecs = list() + for o in m.get(Vocabulary.crosstabSpecs_OP): + self.crosstabSpecs.append(CrosstabSpecBase.createFromJson(o)) @classmethod def createFromJson(cls, m): @@ -6586,12 +6532,9 @@ def toJson(self): m[Vocabulary.SUBKIND] = self.subKind else: m.pop(Vocabulary.SUBKIND, None) - m[Vocabulary.ontologyUri_DP] = self.ontologyUri m[Vocabulary.ontologyVersion_DP] = self.ontologyVersion - m[Vocabulary.inputSpecs_OP] = list( - map(lambda x: x.toJson(), self.inputSpecs)) - m[Vocabulary.outputSpecs_OP] = list( - map(lambda x: x.toJson(), self.outputSpecs)) + m[Vocabulary.crosstabSpecs_OP] = list( + map(lambda x: x.toJson(), self.crosstabSpecs)) return m @@ -8207,43 +8150,6 @@ def toJson(self): return m -class OperatorInputSpecBase(BaseObject): - def __init__(self, m=None): - import tercen.model.impl as impl - if m is not None: - self.fromJson(m) - - else: - super().__init__(m) - - def fromJson(self, m): - import tercen.model.impl as impl - super().fromJson(m) - self.subKind = m.get(Vocabulary.SUBKIND) - if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.OperatorInputSpec_CLASS: - self.subKind = m.get(Vocabulary.KIND) - - @classmethod - def createFromJson(cls, m): - import tercen.model.impl as impl - kind = m.get(Vocabulary.KIND) - if kind == Vocabulary.OperatorInputSpec_CLASS: - return impl.OperatorInputSpec(m) - if kind == Vocabulary.CrosstabSpec_CLASS: - return impl.CrosstabSpec(m) - raise ValueError("bad kind : " + kind + - " for class OperatorInputSpec in createFromJson") - - def toJson(self): - m = super().toJson() - m[Vocabulary.KIND] = Vocabulary.OperatorInputSpec_CLASS - if self.subKind is not None and self.subKind != Vocabulary.OperatorInputSpec_CLASS: - m[Vocabulary.SUBKIND] = self.subKind - else: - m.pop(Vocabulary.SUBKIND, None) - return m - - class ChartSizeBase(BaseObject): def __init__(self, m=None): import tercen.model.impl as impl @@ -9995,7 +9901,6 @@ def toJson(self): class CrosstabSpecBase(BaseObject): def __init__(self, m=None): import tercen.model.impl as impl - CrosstabSpecBase.__bases__ = (impl.OperatorInputSpec,) if m is None: super().__init__(m) self.metaFactors = list() @@ -10005,7 +9910,6 @@ def __init__(self, m=None): def fromJson(self, m): import tercen.model.impl as impl - CrosstabSpecBase.__bases__ = (impl.OperatorInputSpec,) super().fromJson(m) self.subKind = m.get(Vocabulary.SUBKIND) if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.CrosstabSpec_CLASS: @@ -11353,25 +11257,34 @@ def toJson(self): class MappingFactorBase(BaseObject): def __init__(self, m=None): import tercen.model.impl as impl - MappingFactorBase.__bases__ = (impl.MetaFactor,) + MappingFactorBase.__bases__ = (impl.Factor,) if m is None: super().__init__(m) - self.factorName = "" self.isSingle = True + self.description = "" + self.factorName = "" self.isRequired = True + self.factors = list() else: self.fromJson(m) def fromJson(self, m): import tercen.model.impl as impl - MappingFactorBase.__bases__ = (impl.MetaFactor,) + MappingFactorBase.__bases__ = (impl.Factor,) super().fromJson(m) self.subKind = m.get(Vocabulary.SUBKIND) if self.subKind is None and m.get(Vocabulary.KIND) != Vocabulary.MappingFactor_CLASS: self.subKind = m.get(Vocabulary.KIND) - self.factorName = m[Vocabulary.factorName_DP] self.isSingle = m[Vocabulary.isSingle_DP] + self.description = m[Vocabulary.description_DP] + self.factorName = m[Vocabulary.factorName_DP] self.isRequired = m[Vocabulary.isRequired_DP] + if m.get(Vocabulary.factors_OP) is None: + self.factors = list() + else: + self.factors = list() + for o in m.get(Vocabulary.factors_OP): + self.factors.append(FactorBase.createFromJson(o)) @classmethod def createFromJson(cls, m): @@ -11389,8 +11302,11 @@ def toJson(self): m[Vocabulary.SUBKIND] = self.subKind else: m.pop(Vocabulary.SUBKIND, None) - m[Vocabulary.factorName_DP] = self.factorName m[Vocabulary.isSingle_DP] = self.isSingle + m[Vocabulary.description_DP] = self.description + m[Vocabulary.factorName_DP] = self.factorName + m[Vocabulary.factors_OP] = list( + map(lambda x: x.toJson(), self.factors)) m[Vocabulary.isRequired_DP] = self.isRequired return m diff --git a/tercen/model/impl.py b/tercen/model/impl.py index 100cd5f..8b25093 100644 --- a/tercen/model/impl.py +++ b/tercen/model/impl.py @@ -60,10 +60,6 @@ class StorageProfile(StorageProfileBase): def __init__(self, m=None): super().__init__(m) -class OperatorOutputSpec(OperatorOutputSpecBase): - def __init__(self, m=None): - super().__init__(m) - class ResourceSummary(ResourceSummaryBase): def __init__(self, m=None): super().__init__(m) @@ -340,10 +336,6 @@ class RDescription(RDescriptionBase): def __init__(self, m=None): super().__init__(m) -class Factor(FactorBase): - def __init__(self, m=None): - super().__init__(m) - class MetaFactor(MetaFactorBase): def __init__(self, m=None): super().__init__(m) @@ -404,6 +396,10 @@ class Principal(PrincipalBase): def __init__(self, m=None): super().__init__(m) +class Factor(FactorBase): + def __init__(self, m=None): + super().__init__(m) + class Attribute(AttributeBase): def __init__(self, m=None): super().__init__(m) @@ -584,10 +580,6 @@ class RenameRelation(RenameRelationBase): def __init__(self, m=None): super().__init__(m) -class OperatorInputSpec(OperatorInputSpecBase): - def __init__(self, m=None): - super().__init__(m) - class ChartSize(ChartSizeBase): def __init__(self, m=None): super().__init__(m) diff --git a/tercen/model/vocabulary.py b/tercen/model/vocabulary.py index da48728..20c1716 100644 --- a/tercen/model/vocabulary.py +++ b/tercen/model/vocabulary.py @@ -6,7 +6,6 @@ RunningState_CLASS = "RunningState"; WhereRelation_CLASS = "WhereRelation"; StorageProfile_CLASS = "StorageProfile"; -OperatorOutputSpec_CLASS = "OperatorOutputSpec"; ResourceSummary_CLASS = "ResourceSummary"; BillingInfo_CLASS = "BillingInfo"; PatchRecords_CLASS = "PatchRecords"; @@ -129,7 +128,6 @@ RunWorkflowTask_CLASS = "RunWorkflowTask"; GraphicalFactor_CLASS = "GraphicalFactor"; RenameRelation_CLASS = "RenameRelation"; -OperatorInputSpec_CLASS = "OperatorInputSpec"; ChartLine_CLASS = "ChartLine"; ColorList_CLASS = "ColorList"; RelationStep_CLASS = "RelationStep"; @@ -343,9 +341,9 @@ License_DP = "License"; MD5sum_DP = "MD5sum"; NeedsCompilation_DP = "NeedsCompilation"; -ontologyMapping_DP = "ontologyMapping"; crosstabMapping_DP = "crosstabMapping"; -cardinality_DP = "cardinality"; +metaCardinality_DP = "metaCardinality"; +ontologyMapping_DP = "ontologyMapping"; data_dir_DP = "data_dir"; value_DP = "value"; folderId_DP = "folderId"; @@ -366,7 +364,6 @@ operatorId_DP = "operatorId"; testRequired_DP = "testRequired"; targetUrl_DP = "targetUrl"; -ontologyUri_DP = "ontologyUri"; ontologyVersion_DP = "ontologyVersion"; key_DP = "key"; contentType_DP = "contentType"; @@ -469,8 +466,8 @@ valueType_DP = "valueType"; nCalls_DP = "nCalls"; sortOrder_DP = "sortOrder"; -factorName_DP = "factorName"; isSingle_DP = "isSingle"; +factorName_DP = "factorName"; providerKey_DP = "providerKey"; checkoutSessionId_DP = "checkoutSessionId"; subscriptionId_DP = "subscriptionId"; @@ -528,7 +525,6 @@ axis_OP = "axis"; columnTable_OP = "columnTable"; rowTable_OP = "rowTable"; -operatorSpec_OP = "operatorSpec"; schema_OP = "schema"; params_OP = "params"; date_OP = "date"; @@ -548,8 +544,7 @@ urls_OP = "urls"; url_OP = "url"; chart_OP = "chart"; -inputSpecs_OP = "inputSpecs"; -outputSpecs_OP = "outputSpecs"; +crosstabSpecs_OP = "crosstabSpecs"; inMemoryTable_OP = "inMemoryTable"; namedFilter_OP = "namedFilter"; principals_OP = "principals"; @@ -584,6 +579,7 @@ runDate_OP = "runDate"; completedDate_OP = "completedDate"; aclContext_OP = "aclContext"; +operatorSpec_OP = "operatorSpec"; rightAttributes_OP = "rightAttributes"; steps_OP = "steps"; defaultFactors_OP = "defaultFactors";