Unable to create a deployment using python SDK

  • 23 January 2023
  • 2 replies

After creating an environment through python sdk, when I am trying to create a deployment using the scripts I am getting the error described bellow:


>>>deployment_builder = sch.get_deployment_builder(deployment_type='SELF')
>>> # sample_environment is an instance of streamsets.sdk.sch_models.SelfManagedEnvironment
>>> deployment ='Sample Deployment',
...                                       environment=sample_environment,
...                                       engine_type='DC',
...                                       engine_version='4.1.0',
...                                       deployment_tags=['self-managed-tag'])

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
NameError: name 'sample_environment' is not defined

Please help me regarding this.

2 replies

Userlevel 3
Badge +1


Can you please try this with your configuration details .


from streamsets.sdk import ControlHub

sch = ControlHub(credential_id='your_crediential_id', token='your_token_id')

sdc = sch.data_collectors.get(url='http://your_data_collector_hostname:18630')

builder = sch.get_pipeline_builder(engine_type='data_collector',

dev_raw_data_source = builder.add_stage('Dev Raw Data Source')

trash = builder.add_stage('Trash')

dev_raw_data_source >> trash

pipeline ='My first pipeline')

sch.publish_pipeline(pipeline, commit_message='First commit of my first pipeline')

Userlevel 4


Create an instance of environment first and use its reference in the deployment.