{"id":3418,"date":"2023-04-12T15:33:06","date_gmt":"2023-04-12T15:33:06","guid":{"rendered":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/"},"modified":"2026-01-16T15:15:13","modified_gmt":"2026-01-16T15:15:13","slug":"spss-modeler-basic-stream-automation","status":"publish","type":"post","link":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/","title":{"rendered":"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting?"},"content":{"rendered":"<p>Scripting in Modeler is an extremely powerful way to automate processes and execution of streams. Just about any action that you can perform manually can be automated using the Jython scripting API. This is convenient if you\u2019re running the stream from within Modeler client, and extremely important if you\u2019re running the stream outside of Modeler client (Modeler Batch\/command line\/C&amp;DS). Note that Modeler scripts are written in Jython \u2013 this mean that in addition to modeler-specific API functions you\u2019ll have all the features of Python available as well!<\/p>\n<p>In this article, we\u2019ll talk through some basic scripting functions to get started and run nodes in order.<\/p>\n<p><span style=\"color: #3366ff;\"><strong>Starting a Script<\/strong><\/span><\/p>\n<p>To navigate to the scripting window, you can click the pencil icon at the top of the screen to open the stream properties window and navigate to the Execution tab:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1163\" src=\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg\" alt=\"\" width=\"1163\" height=\"838\" \/><\/p>\n<p>For any script, the first thing you\u2019ll want to do is import the modeler API library. This can be done with a simple \u2018import\u2019 command:<\/p>\n<p style=\"padding-left: 80px;\">import modeler.api<\/p>\n<p>This will enable the script to use modeler-specific functions. You can also add any other Python libraries here by separating them with commas.<\/p>\n<p>Next, you\u2019ll want to define your stream object \u2013 or give the script a way to reference the modeler stream itself. This can be done in a single command:<\/p>\n<p>stream = modeler.script.stream()<\/p>\n<p>With this combination of loading the modeler API and defining the reference to the stream, you\u2019ll be able to run stream-specific functions like running nodes!<\/p>\n<p><span style=\"color: #3366ff;\"><strong>Running a Node<\/strong><\/span><\/p>\n<p>The command to run a node is broken into two pieces \u2013 1. Finding a node and 2. Running it. Finding a node simply gives you a way to refer to a specific node and perform operations on it. This might include setting node properties, connecting it to other nodes, or running it. The most common \u2018find\u2019 function is called findByType. This allows you to find a node based on its type (database source, filler, etc.), or its name. In this example, we\u2019ll find two nodes by their names and run them in order.<\/p>\n<p>When scripting, it\u2019s recommended to give each node a unique name using the Annotations tab. In this stream, we\u2019ve got two branches of source nodes to export nodes called \u2018Export_1\u2019 and \u2018Export_2\u2019:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1164\" src=\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/basic2-min.jpg\" alt=\"\" width=\"867\" height=\"260\" \/><\/p>\n<p>We can then use this unique name in the findByType function as follows:<\/p>\n<p style=\"padding-left: 80px;\">exportNode1 = stream.findByType(None,&#8217;Export_1&#8242;)<\/p>\n<p>This function takes two arguments: a node type (database source, filler, etc.) and a node name. If you\u2019re referring to a unique name, as we are in this example, you can pass in a value of None into the type argument and find the node solely on its name.<\/p>\n<p>This will create a variable called exportNode1 that is a direct reference to the node named \u201cExport_1\u201d.<\/p>\n<p>To run the node, we can call the run command:<\/p>\n<p>exportNode1.run([])<\/p>\n<p>We can then follow the same process for the second node, and run both nodes with a complete script of:<\/p>\n<p style=\"padding-left: 40px;\">import modeler.api<\/p>\n<p>stream = modeler.script.stream()<\/p>\n<p style=\"padding-left: 40px;\">exportNode1 = stream.findByType(None,&#8217;Export_1&#8242;)<\/p>\n<p style=\"padding-left: 40px;\">exportNode2 = stream.findByType(None,&#8217;Export_2&#8242;)<\/p>\n<p style=\"padding-left: 40px;\">exportNode1.run([])<\/p>\n<p style=\"padding-left: 40px;\">exportNode2.run([])<\/p>\n<p>Scripts always run from top to bottom, so exportNode1 will run and complete before running exportNode2.<\/p>\n<p><strong>Note: <\/strong>Just like when running from the GUI, you\u2019ll only need to reference and run the <strong>terminal node<\/strong> of any branch.<\/p>\n<p>Using this methodology you can script your streams to run any number of nodes in order, just pass the name into the find function. Note that by default, the run option on the script is to be ignored:<\/p>\n<p>If you click \u2018Run this script\u2019, then hitting the Run button on the stream will run the script.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1165\" src=\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/basic3-min.jpg\" alt=\"\" width=\"425\" height=\"648\" \/><\/p>\n<p>IBM\u2019s documentation can be extremely useful to expand your knowledge of scripting and automation of streams, you can find it here:<\/p>\n<p><a href=\"ftp:\/\/public.dhe.ibm.com\/software\/analytics\/spss\/documentation\/modeler\/18.1\/en\/ModelerScriptingAutomation.pdf\">ftp:\/\/public.dhe.ibm.com\/software\/analytics\/spss\/documentation\/modeler\/18.1\/en\/ModelerScriptingAutomation.pdf<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scripting in Modeler is an extremely powerful way to automate processes and execution of streams. Just about any action that you can perform manually can be automated using the Jython scripting API. This is convenient if you\u2019re running the stream from within Modeler client, and extremely important if you\u2019re running the stream outside of Modeler&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[24],"tags":[38,44,57],"class_list":["post-3418","post","type-post","status-publish","format-standard","hentry","category-ibm","tag-how-tos","tag-spss","tag-spss-how-tos"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting? - QueBIT<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting? - QueBIT\" \/>\n<meta property=\"og:description\" content=\"Scripting in Modeler is an extremely powerful way to automate processes and execution of streams. Just about any action that you can perform manually can be automated using the Jython scripting API. This is convenient if you\u2019re running the stream from within Modeler client, and extremely important if you\u2019re running the stream outside of Modeler&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\" \/>\n<meta property=\"og:site_name\" content=\"QueBIT\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-12T15:33:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-16T15:15:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2023\/02\/cardone.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"410\" \/>\n\t<meta property=\"og:image:height\" content=\"327\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"agoddard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"agoddard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\"},\"author\":{\"name\":\"agoddard\",\"@id\":\"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084\"},\"headline\":\"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting?\",\"datePublished\":\"2023-04-12T15:33:06+00:00\",\"dateModified\":\"2026-01-16T15:15:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\"},\"wordCount\":664,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg\",\"keywords\":[\"How To\u2019s\",\"SPSS\",\"SPSS How To's\"],\"articleSection\":[\"IBM\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\",\"url\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\",\"name\":\"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting? - QueBIT\",\"isPartOf\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg\",\"datePublished\":\"2023-04-12T15:33:06+00:00\",\"dateModified\":\"2026-01-16T15:15:13+00:00\",\"author\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084\"},\"breadcrumb\":{\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage\",\"url\":\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg\",\"contentUrl\":\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/quebit.com\/askquebit\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/quebit.com\/askquebit\/#website\",\"url\":\"https:\/\/quebit.com\/askquebit\/\",\"name\":\"QueBIT\",\"description\":\"QueBIT\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/quebit.com\/askquebit\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084\",\"name\":\"agoddard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g\",\"caption\":\"agoddard\"},\"sameAs\":[\"https:\/\/quebit.com\/askquebit\"],\"url\":\"https:\/\/quebit.com\/askquebit\/author\/agoddard\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting? - QueBIT","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/","og_locale":"en_US","og_type":"article","og_title":"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting? - QueBIT","og_description":"Scripting in Modeler is an extremely powerful way to automate processes and execution of streams. Just about any action that you can perform manually can be automated using the Jython scripting API. This is convenient if you\u2019re running the stream from within Modeler client, and extremely important if you\u2019re running the stream outside of Modeler&hellip;","og_url":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/","og_site_name":"QueBIT","article_published_time":"2023-04-12T15:33:06+00:00","article_modified_time":"2026-01-16T15:15:13+00:00","og_image":[{"width":410,"height":327,"url":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2023\/02\/cardone.jpg","type":"image\/jpeg"}],"author":"agoddard","twitter_card":"summary_large_image","twitter_misc":{"Written by":"agoddard","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#article","isPartOf":{"@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/"},"author":{"name":"agoddard","@id":"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084"},"headline":"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting?","datePublished":"2023-04-12T15:33:06+00:00","dateModified":"2026-01-16T15:15:13+00:00","mainEntityOfPage":{"@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/"},"wordCount":664,"commentCount":0,"image":{"@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage"},"thumbnailUrl":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg","keywords":["How To\u2019s","SPSS","SPSS How To's"],"articleSection":["IBM"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/","url":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/","name":"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting? - QueBIT","isPartOf":{"@id":"https:\/\/quebit.com\/askquebit\/#website"},"primaryImageOfPage":{"@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage"},"image":{"@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage"},"thumbnailUrl":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg","datePublished":"2023-04-12T15:33:06+00:00","dateModified":"2026-01-16T15:15:13+00:00","author":{"@id":"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084"},"breadcrumb":{"@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#primaryimage","url":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg","contentUrl":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/07\/Basic1-min.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/quebit.com\/askquebit\/spss-modeler-basic-stream-automation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/quebit.com\/askquebit\/"},{"@type":"ListItem","position":2,"name":"How Do I Automate SPSS Modeler Streams Using Basic Jython Scripting?"}]},{"@type":"WebSite","@id":"https:\/\/quebit.com\/askquebit\/#website","url":"https:\/\/quebit.com\/askquebit\/","name":"QueBIT","description":"QueBIT","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/quebit.com\/askquebit\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084","name":"agoddard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g","caption":"agoddard"},"sameAs":["https:\/\/quebit.com\/askquebit"],"url":"https:\/\/quebit.com\/askquebit\/author\/agoddard\/"}]}},"_links":{"self":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts\/3418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/comments?post=3418"}],"version-history":[{"count":2,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts\/3418\/revisions"}],"predecessor-version":[{"id":4952,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts\/3418\/revisions\/4952"}],"wp:attachment":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/media?parent=3418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/categories?post=3418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/tags?post=3418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}