{"id":1438,"date":"2018-03-28T14:00:47","date_gmt":"2020-02-18T06:55:22","guid":{"rendered":"https:\/\/redfrontdoor.org\/blg2\/?p=1438"},"modified":"2020-02-18T16:51:36","modified_gmt":"2020-02-18T16:51:36","slug":"post-1432","status":"publish","type":"post","link":"https:\/\/redfrontdoor.org\/blog\/?p=1438","title":{"rendered":"Compiling Python into an AWS Step Function"},"content":{"rendered":"<p>Amazon provide a <a href=\"https:\/\/aws.amazon.com\/\">very large collection of services<\/a> for running your computations, websites, etc., on their infrastructure.  One of the approaches these services enable is &#8216;<em>serverless computing<\/em>&#8216;, which, as <a href=\"https:\/\/aws.amazon.com\/serverless\/\">they put it<\/a>, lets you &#8216;build and run applications and services without thinking about servers&#8217;.<\/p>\n<p>Two of the components of this are &#8216;<a href=\"https:\/\/aws.amazon.com\/lambda\/\">Lambda<\/a>&#8216; and &#8216;<a href=\"https:\/\/aws.amazon.com\/step-functions\/\">Step Functions<\/a>&#8216;.  Very briefly: Lambda lets you upload Python (or Go, or&#8230;) code and leave Amazon work out where to run it.  Step Functions allow you to coordinate multiple interlinked stages of a computation, which can include Lambda invocations.<\/p>\n<p>To specify a Step Function, you describe a state machine in JSON.  This struck me as cumbersome compared to the normal way we describe how we want multiple components of a computation to work together: normally, we write a Python (or Go, or&#8230;) program.  To explore this idea, I put together a &#8216;plausibility argument of concept&#8217; for the idea that Python could be compiled into a Step Function specification:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/bennorth\/pyawssfn\">Compiling Python into AWS Lambda \/ Step Function<\/a> [GitHub]<\/li>\n<\/ul>\n<p>For example, the top-level function <a href=\"https:\/\/github.com\/bennorth\/pyawssfn\/blob\/master\/analyse_text.py#L69\"><tt>summarise()<\/tt><\/a> (22 non-blank lines) gets turned into <a href=\"https:\/\/github.com\/bennorth\/pyawssfn\/blob\/master\/stepfun.json\">196 lines of JSON<\/a>.<\/p>\n<p>There would be <a href=\"https:\/\/github.com\/bennorth\/pyawssfn\/blob\/master\/future-work.md\">plenty still to do<\/a> to turn this into something production-ready, but I think the idea has promise.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A &#8216;plausibility argument of concept&#8217; for the idea that normal Python code can be compiled into a &#8216;Lambda function&#8217; and a &#8216;Step Function&#8217; for use on Amazon Web Services.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1438","post","type-post","status-publish","format-standard","hentry","category-uncategorized","comments-off"],"_links":{"self":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1438"}],"version-history":[{"count":1,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1438\/revisions"}],"predecessor-version":[{"id":2166,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1438\/revisions\/2166"}],"wp:attachment":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}