from __future__ import print_function

import time

from simpleflow import (
    activity,
    Workflow,
    futures,
)


@activity.with_attributes(task_list='quickstart', version='example')
def repeat50k(s):
    return s * 50000


@activity.with_attributes(task_list='quickstart', version='example')
def length(x):
    return len(x)


class JumboFieldsWorkflow(Workflow):
    """
    This workflow demonstrates how you can use simpleflow jumbo fields, e.g.
    how simpleflow can automatically store input/results on S3 if their length
    crosses the SWF limits (32KB for input/results).
    """
    name = 'basic'
    version = 'example'
    task_list = 'example'

    def run(self, string):
        long_string = self.submit(repeat50k, str(string))
        string_length = self.submit(length, long_string)
        print('{} * 50k has a length of: {}'.format(
            string, string_length.result))

from __future__ import print_function

import os

from simpleflow import Workflow, activity


@activity.with_attributes(task_list='quickstart', version='example')
def repeat50k(s):
    return s * 50000


@activity.with_attributes(task_list='quickstart', version='example')
def length(x):
    return len(x)


class JumboFieldsWorkflow(Workflow):
    """
    This workflow demonstrates how you can use simpleflow jumbo fields, e.g.
    how simpleflow can automatically store input/results on S3 if their length
    crosses the SWF limits (32KB for input/results).
    """
    name = 'basic'
    version = 'example'
    task_list = 'example'

    def run(self, string):
        if 'SIMPLEFLOW_JUMBO_FIELDS_BUCKET' not in os.environ:
            print("Please define SIMPLEFLOW_JUMBO_FIELDS_BUCKET to run this example (see README.rst).")
            raise ValueError()
        long_string = self.submit(repeat50k, str(string))
        string_length = self.submit(length, long_string)
        print('{} * 50k has a length of: {}'.format(
            string, string_length.result))

Make JumboFieldsWorkflow fail if no env var
Make JumboFieldsWorkflow fail if no env var

If SIMPLEFLOW_JUMBO_FIELDS_BUCKET is not set, the example doesn't work;
make this clear.

Signed-off-by: Yves Bastide <3b1fe340dba76bf37270abad774f327f50b5e1d8@botify.com>

  from __future__ import print_function
  
- import time
+ import os
  
+ from simpleflow import Workflow, activity
- from simpleflow import (
-     activity,
-     Workflow,
-     futures,
- )
  
  
  @activity.with_attributes(task_list='quickstart', version='example')
  def repeat50k(s):
      return s * 50000
  
  
  @activity.with_attributes(task_list='quickstart', version='example')
  def length(x):
      return len(x)
  
  
  class JumboFieldsWorkflow(Workflow):
      """
      This workflow demonstrates how you can use simpleflow jumbo fields, e.g.
      how simpleflow can automatically store input/results on S3 if their length
      crosses the SWF limits (32KB for input/results).
      """
      name = 'basic'
      version = 'example'
      task_list = 'example'
  
      def run(self, string):
+         if 'SIMPLEFLOW_JUMBO_FIELDS_BUCKET' not in os.environ:
+             print("Please define SIMPLEFLOW_JUMBO_FIELDS_BUCKET to run this example (see README.rst).")
+             raise ValueError()
          long_string = self.submit(repeat50k, str(string))
          string_length = self.submit(length, long_string)
          print('{} * 50k has a length of: {}'.format(
              string, string_length.result))
  
Make JumboFieldsWorkflow fail if no env var
## Code Before:
from __future__ import print_function

import time

from simpleflow import (
    activity,
    Workflow,
    futures,
)


@activity.with_attributes(task_list='quickstart', version='example')
def repeat50k(s):
    return s * 50000


@activity.with_attributes(task_list='quickstart', version='example')
def length(x):
    return len(x)


class JumboFieldsWorkflow(Workflow):
    """
    This workflow demonstrates how you can use simpleflow jumbo fields, e.g.
    how simpleflow can automatically store input/results on S3 if their length
    crosses the SWF limits (32KB for input/results).
    """
    name = 'basic'
    version = 'example'
    task_list = 'example'

    def run(self, string):
        long_string = self.submit(repeat50k, str(string))
        string_length = self.submit(length, long_string)
        print('{} * 50k has a length of: {}'.format(
            string, string_length.result))

## Instruction:
Make JumboFieldsWorkflow fail if no env var
## Code After:
from __future__ import print_function

import os

from simpleflow import Workflow, activity


@activity.with_attributes(task_list='quickstart', version='example')
def repeat50k(s):
    return s * 50000


@activity.with_attributes(task_list='quickstart', version='example')
def length(x):
    return len(x)


class JumboFieldsWorkflow(Workflow):
    """
    This workflow demonstrates how you can use simpleflow jumbo fields, e.g.
    how simpleflow can automatically store input/results on S3 if their length
    crosses the SWF limits (32KB for input/results).
    """
    name = 'basic'
    version = 'example'
    task_list = 'example'

    def run(self, string):
        if 'SIMPLEFLOW_JUMBO_FIELDS_BUCKET' not in os.environ:
            print("Please define SIMPLEFLOW_JUMBO_FIELDS_BUCKET to run this example (see README.rst).")
            raise ValueError()
        long_string = self.submit(repeat50k, str(string))
        string_length = self.submit(length, long_string)
        print('{} * 50k has a length of: {}'.format(
            string, string_length.result))
