Analytic Server Context
The Context provides support for the Analytic Server Context interface for interaction with the SPSS Analytic Server.
The Context provides support for the Analytic Server context interface for interaction with SPSS Analytic Server.
AnalyticServerContext Objects
AnalyticServerContext
objects set up the context environment which provides
several interfaces for interacting with SPSS Analytic Server. An application that wants to construct
this context instance must do so using the spss.pyspark.runtime.getContext()
interface rather than implementing the interface directly.
Returns the Pyspark python
SparkContext
instance:cxt.getSparkContext() : SparkContext
Returns the Pyspark python
SQLContext
instance:cxt.getSparkSQLContext() : SQLContext
Returns
True
to describe whether the execution is made only to compute the
output data model. Otherwise returns
False
:cxt.isComputeDataModelOnly() : Boolean
Returns
True
if the script is running in the Spark environment. Currently, it
always returns True
:cxt.isSparkExecution() : Boolean
Loads input data from the upstream temporary file and generates the
pyspark.sql.DataFrame
instance:cxt.getSparkInputData() : DataFrame
Returns a
pyspark.sql.StructType
instance generated from the input data model.
Returns None
if the input data model does not
exist:cxt.getSparkInputSchema() : StructType
Serializes the output data frame into Analytic Server context and returns the
context:
cxt.setSparkOutputData( outDF) : AnalyticServerContext
Parameter:
outDF (DataFrame) :
The output data frame value
Exceptions:
DataOutputNotSupported :
If this interface is invoked in the functionpyspark:buildmodel
ASContextException :
If the output data frame isNone
InconsistentOutputDataModel :
The field names and storage type information common to both objects is inconsistent
Converts the
outSchema
StructType
instance into a data model, serializes it into the Analytic Server
context, and returns the
context:cxt.setSparkOutputSchema(outSchema) : AnalyticServerContext
Parameter:
outSchema(StructType) :
The outputStructType
object
Exceptions:
ASContextException :
If the output schema instance isNone
InconsistentOutputDataModel :
The field names and storage type information common to both objects is inconsistent
Stores the location of model building output to the Analytic Server context and returns the
context:
cxt.setModelContentFromPath(key, path, mimetype=None) : AnalyticServerContext
The
path can be a directory path which should use the cxt.createTemporaryFolder()
API
to generate , when everything under the directory is packaged up as model content.Parameters:
key (string) :
key string valuepath (string) :
location of model building output string pathmimetype (string, optional) :
the MIME type of the content
Exceptions:
ModelOutputNotSupported :
When not invoking this API from thepyspark:buildmodel
functionKeyError :
If the key attribute isNone
or the string is empty
Stores the model building content, metadata, or other attributes to the Analytic Server context
and returns the
context:
cxt.setModelContentFromString(key, value, mimetype=None) : AnalyticServerContext
Parameters:
key (string) :
key string valuevalue (string) :
the model metadata string valuemimetype (string, optional) :
the MIME type of the content
Exceptions:
ModelOutputNotSupported :
When not invoking this API from thepyspark:buildmodel
functionKeyError :
If the key attribute isNone
or the string is empty
Returns the temporary folder location that is managed by Analytic Server; this can be used to
store the model content:
cxt.createTemporaryFolder() : string
Exception:
ModelOutputNotSupported :
When not invoking this API from thepyspark:buildmodel
function
Returns the location of the model which matches the input
key:
cxt.getModelContentToPath(key) : string
Parameter:
key (string) :
key string value
Exceptions:
ModelInputNotSupported :
When not invoking this API from thepyspark:applymodel
functionKeyError :
If the key attribute isNone
or the string is emptyIncompatibleModelContentType :
If the model content type is not a container
Returns the model content, metadata of the model, or other model attributes which match the input
key:
cxt.getModelContentToString(key) : string
Parameter:
key (string) :
key string value
Exceptions:
ModelInputNotSupported :
When not invoking this API from thepyspark:applymodel
functionKeyError :
If the key attribute isNone
, or the string is empty, or the key does not existIncompatibleModelContentType :
If the model content type is not consistent
Returns the mime-type assigned to the input key. It returns
None
if the
specified content has no mime
type:cxt.getModelContentMimeType(key) : string
Parameter:
key (string) :
key string value
Exceptions:
ModelInputNotSupported :
When not invoking this API from thepyspark:applymodel
functionKeyError :
If the key attribute isNone
, or the string is empty, or the key does not exist