How to create a Metric Array object in Jupyter for BatchExportSpec for evalMetricsWithMetadata with overrideMetrics


#1

I am trying to run a BatchExport in Jupyter Notebook on metrics I am defining several metrics on the fly using overrideMetrics. overrideMetrics expects an array of metrics objects.

In the static console, I can set overrideMetrics = Metric.array([My,List,Of,Metrics,…])

How do I do this in Jupyter Notebook? In pyc3/c3-Remote, c3.Metric does not have the attribute array.


#2

Can you try the following:

overrideMetrics=[
    c3.CompoundMetric(id=..., name=..., expression=....), 
    c3.CompoundMetric(id=..., name=..., expression=...), 
    c3.SimpleMetric(id=..., name=..., srcType=..., path=..., expression=...)
]

?


#3

I have tried three different approaches.

Option 1 - Pass list of metrics

overrideMetrics=[
c3.CompoundMetric(id=…, name=…, expression=…),
c3.CompoundMetric(id=…, name=…, expression=…),
c3.SimpleMetric(id=…, name=…, srcType=…, path=…, expression=…)
]

Export.startExport took 14.2369 ms

HTTPError Traceback (most recent call last)
in ()
----> 1 export_job = c3.Export.startExport(expSpec2)

in startExport(spec, contentEncoding, deleteExisting, fileList, id, failIfUrlNotEmpty, order, jsonInclude, contentType, doNotRandomizeFileName, csvFormat, targetAction, targetPath, targetType, fileUrlOrEncodedPathPrefix, numFiles, filter, xmlInclude, limit, csvHeader, scheduleBatchSize, numObjPerFile)

/usr/local/share/jupyter/anaconda/envs/Python-py-server__enel-prod/lib/python2.7/site-packages/pyc3/typesys.pyc in hidden_call(**kwargs)
271
272 kwargs = {single_argument.name: kwargs[single_argument.name]}
–> 273 return self.valueType(self.parent_type, self.name, **kwargs)
274 else:
275 raise TypeError("’{}’ object is not callable".format(self.valueType.name))

/usr/local/share/jupyter/anaconda/envs/Python-py-server__enel-prod/lib/python2.7/site-packages/pyc3/typesys.pyc in call(self, parent_type, action, **kwargs)
728 response = _local_scopeaction
729 else:
–> 730 response = typesys._connector.request_json(parent_type, action, kwargs)
731
732 # Instantiate C3 Object

/usr/local/share/jupyter/anaconda/envs/Python-py-server__enel-prod/lib/python2.7/site-packages/pyc3/typesys.pyc in request_json(self, c3type, action, payload, tag)
1245 except:
1246 # If not, re-raise HTTPError
-> 1247 raise e
1248
1249 @staticmethod

HTTPError: 500 Server Error: Server Error for url: https://enel-stage.c3-e.com//api/1/enel/prod/Export?action=startExport


#4

Option 2 - Pass c3.ObjArry (This used to work until v7.7) -

overrideMetrics= c3.ObjArry( value=[
c3.CompoundMetric(id=…, name=…, expression=…),
c3.CompoundMetric(id=…, name=…, expression=…),
c3.SimpleMetric(id=…, name=…, srcType=…, path=…, expression=…)
])

Export jobs is successfully submitted but the following error message appears:

Export.status took 14.8182 ms
{
“type”: {
“name”: “BatchJobStatus”
},
“errors”: [
{
“failedActionId”: “7872.132428052”,
“errorMsg”: “Unable to coerce [any] value of ServicePoint.evalMetricsWithMetadata#overrideMetrics to [Metric]”,
“errorCodes”: “NotClassified”,


#5

Option 3 - c3.Metric

overrideMetrics= c3.Metric( value=[
c3.CompoundMetric(id=…, name=…, expression=…),
c3.CompoundMetric(id=…, name=…, expression=…),
c3.SimpleMetric(id=…, name=…, srcType=…, path=…, expression=…)
])

Job submission fails with:

Export.startExport took 13.8502 ms

HTTPError Traceback (most recent call last)
in ()
----> 1 export_job = c3.Export.startExport(expSpec2)

in startExport(spec, contentEncoding, deleteExisting, fileList, id, failIfUrlNotEmpty, order, jsonInclude, contentType, doNotRandomizeFileName, csvFormat, targetAction, targetPath, targetType, fileUrlOrEncodedPathPrefix, numFiles, filter, xmlInclude, limit, csvHeader, scheduleBatchSize, numObjPerFile)

/usr/local/share/jupyter/anaconda/envs/Python-py-server__enel-prod/lib/python2.7/site-packages/pyc3/typesys.pyc in hidden_call(**kwargs)
271
272 kwargs = {single_argument.name: kwargs[single_argument.name]}
–> 273 return self.valueType(self.parent_type, self.name, **kwargs)
274 else:
275 raise TypeError("’{}’ object is not callable".format(self.valueType.name))

/usr/local/share/jupyter/anaconda/envs/Python-py-server__enel-prod/lib/python2.7/site-packages/pyc3/typesys.pyc in call(self, parent_type, action, **kwargs)
728 response = _local_scopeaction
729 else:
–> 730 response = typesys._connector.request_json(parent_type, action, kwargs)
731
732 # Instantiate C3 Object

/usr/local/share/jupyter/anaconda/envs/Python-py-server__enel-prod/lib/python2.7/site-packages/pyc3/typesys.pyc in request_json(self, c3type, action, payload, tag)
1245 except:
1246 # If not, re-raise HTTPError
-> 1247 raise e
1248
1249 @staticmethod

HTTPError: 400 Client Error: Bad Request for url: https://enel-stage.c3-e.com//api/1/enel/prod/Export?action=startExport


#6

After working with Isaiah, we discovered the following works

overrideMetrics = {"type" :  "[Metric]", 
"value" : [
    c3.CompoundMetric(id=..., name=..., expression=....), 
    c3.CompoundMetric(id=..., name=..., expression=...), 
    c3.SimpleMetric(id=..., name=..., srcType=..., path=..., expression=...)
]}