streamsx.topology.context module

class streamsx.topology.context.ConfigParams

Bases: object

Configuration options which may be used as keys in the submit’s config parameter.

VCAP_SERVICES - a json object containing the VCAP information used to submit to Bluemix SERVICE_NAME - the name of the streaming analytics service to use from VCAP_SERVICES.

FORCE_REMOTE_BUILD = 'topology.forceRemoteBuild'
JOB_CONFIG = 'topology.jobConfigOverlays'

Key for a JobConfig object representing a job configuration for a submission.

SERVICE_NAME = 'topology.service.name'
VCAP_SERVICES = 'topology.service.vcap'
class streamsx.topology.context.ContextTypes

Bases: object

Types of submission contexts:

DISTRIBUTED - the topology is submitted to a Streams instance. The bundle is submitted using streamtool which must be setup to submit without requiring authentication input. Additionally, a username and password may optionally be provided to enable retrieving data from remote views. STANDALONE - the topology is executed directly as an Streams standalone application. The standalone execution is spawned as a separate process BUNDLE - execution of the topology produces an SPL application bundle (.sab file) that can be submitted to an IBM Streams instance as a distributed application. STANDALONE_BUNDLE - execution of the topology produces an SPL application bundle that, when executed, is spawned as a separate process. JUPYTER - the topology is run in standalone mode, and context.submit returns a stdout streams of bytes which can be read from to visualize the output of the application. BUILD_ARCHIVE - Creates a Bluemix-compatible build archive. execution of the topology produces a build archive, which can be submitted to a streaming analytics Bluemix remote build service. TOOLKIT - Execution of the topology produces a toolkit. ANALYTICS_SERVICE - If a local Streams install is present, the application is built locally and then submitted to a Bluemix streaming analytics service. If a local Streams install is not present, the application is submitted to, built, and executed on a Bluemix streaming analytics service. If the ConfigParams.REMOTE_BUILD flag is set to true, the application will be built on Bluemix even if a local Streams install is present.

ANALYTICS_SERVICE = 'ANALYTICS_SERVICE'
BUILD_ARCHIVE = 'BUILD_ARCHIVE'
BUNDLE = 'BUNDLE'
DISTRIBUTED = 'DISTRIBUTED'
JUPYTER = 'JUPYTER'
STANDALONE = 'STANDALONE'
STANDALONE_BUNDLE = 'STANDALONE_BUNDLE'
TOOLKIT = 'TOOLKIT'
class streamsx.topology.context.JobConfig(job_name=None, job_group=None, preload=False, data_directory=None)

Bases: object

Job configuration.

JobConfig allows configuration of job that will result from submission of a py:class:Topology (application).

A JobConfig is set in the config dictionary passed to submit() using the key JOB_CONFIG. add() exists as a convenience method to add it to a submission configuration.

Parameters:
  • job_name (str) – The name that is assigned to the job. A job name must be unique within a Streasm instance When set to None a system generated name is used.
  • job_group (str) – The job group to use to control permissions for the submitted job.
  • preload (bool) – Specifies whether to preload the job onto all resources in the instance, even if the job is not currently needed on each. Preloading the job can improve PE restart performance if the PEs are relocated to a new resource.
  • data_directory (str) – Specifies the location of the optional data directory. The data directory is a path within the cluster that is running the Streams instance.

Example:

# Submit a job with the name NewsIngester
cfg = {}
job_config = JobConfig(job_name='NewsIngester')
job_config.add(cfg)
context.submit('ANALYTICS_SERVICE', topo, cfg)
add(config)

Add this JobConfig into a submission configuration object.

Parameters:config (dict) – Submission configuration.
Returns:config.
Return type:dict
exception streamsx.topology.context.UnsupportedContextException(msg)

Bases: Exception

An exeption class for when something goes wrong with submitting using a particular context.

streamsx.topology.context.submit(ctxtype, graph, config=None, username=None, password=None)

Submits a topology with the specified context type.

Parameters:
  • ctxtype (string) – context type. Values include:
  • DISTRIBUTED - the topology is submitted to a Streams instance. (*) – The bundle is submitted using streamtool which must be setup to submit without requiring authentication input. Additionally, a username and password may optionally be provided to enable retrieving data from remote views.
  • STANDALONE - the topology is executed directly as an Streams standalone application. (*) – The standalone execution is spawned as a separate process
  • BUNDLE - execution of the topology produces an SPL application bundle (*) – (.sab file) that can be submitted to an IBM Streams instance as a distributed application.
  • JUPYTER - the topology is run in standalone mode, and context.submit returns a stdout streams of bytes which (*) – can be read from to visualize the output of the application.
  • BUILD_ARCHIVE - Creates a Bluemix-compatible build archive. (*) – execution of the topology produces a build archive, which can be submitted to a streaming analytics Bluemix remote build service.
  • ANALYTICS_SERVICE - If a local IBM Streams install is present, the application is built locally and then submitted (*) – to an IBM Bluemix Streaming Analytics service. If a local IBM Streams install is not present, the application is submitted to, built, and executed on an IBM Bluemix Streaming Analytics service. If the ConfigParams.FORCE_REMOTE_BUILD flag is set to True, the application will be built by the service even if a local Streams install is present. The service is described by its VCAP services and a service name pointing to an instance within the VCAP services. The VCAP services is either set in the configuration object or as the environment variable VCAP_SERVICES.
  • graph – a Topology object.
  • config (dict) – a configuration object containing job configurations and/or submission information. Keys include:
  • ConfigParams.VCAP_SERVICES (*) –
  • ConfigParams.SERVICE_NAME (*) –
  • ConfigParams.FORCE_REMOTE_BUILD (*) –
  • username (string) – an optional SWS username. Needed for retrieving remote view data.
  • password (string) – an optional SWS password. Used in conjunction with the username, and needed for retrieving
  • view data. (remote) –
  • log_level – The maximum logging level for log output.
Returns:

An output stream of bytes if submitting with JUPYTER, otherwise returns a dict containing information relevant to the submission.