diff --git a/examples/python_initialize.dig b/examples/python_initialize.dig new file mode 100644 index 0000000000..29814f1c58 --- /dev/null +++ b/examples/python_initialize.dig @@ -0,0 +1,11 @@ +_export: + py: + require: tasks.initialize.InstanceVariable + arg1: var1 + arg2: var2 + ++step1: + py>: tasks.initialize.InstanceVariable.step1 + ++step2: + py>: tasks.initialize.InstanceVariable.step2 diff --git a/examples/ruby_initialize.dig b/examples/ruby_initialize.dig new file mode 100644 index 0000000000..dad36faa05 --- /dev/null +++ b/examples/ruby_initialize.dig @@ -0,0 +1,11 @@ +_export: + rb: + require: 'tasks/initialize' + arg1: var1 + arg2: var2 + ++step1: + rb>: InstanceVariable.step1 + ++step2: + rb>: InstanceVariable.step2 diff --git a/examples/tasks/initialize.py b/examples/tasks/initialize.py new file mode 100644 index 0000000000..ff77ac9d7c --- /dev/null +++ b/examples/tasks/initialize.py @@ -0,0 +1,17 @@ +import digdag + +class InstanceVariable: + def __init__(self, arg1): + self.arg1 = arg1 + + def step1(self): + print(self.arg1) + print(digdag.env.params['arg1']) + print(digdag.env.params['arg2']) + print('self.arg1 is modified!!!') + self.arg1 = 'var3' + print(self.arg1) + + def step2(self): + print('Instance variables is initialized by each tasks.') + print(self.arg1) diff --git a/examples/tasks/initialize.rb b/examples/tasks/initialize.rb new file mode 100644 index 0000000000..438e9e8719 --- /dev/null +++ b/examples/tasks/initialize.rb @@ -0,0 +1,19 @@ +class InstanceVariable + def initialize(arg1) + @var = arg1 + end + + def step1 + puts @var + puts Digdag.env.params['arg1'] + puts Digdag.env.params['arg2'] + puts '@var is modified!!!' + @var = 'var3' + puts @var + end + + def step2 + puts "Instance variables is initialized by each tasks." + puts @var + end +end