Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language api class init examples #1734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/python_initialize.dig
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions examples/ruby_initialize.dig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_export:
rb:
require: 'tasks/initialize'
arg1: var1
arg2: var2

+step1:
rb>: InstanceVariable.step1

+step2:
rb>: InstanceVariable.step2
17 changes: 17 additions & 0 deletions examples/tasks/initialize.py
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions examples/tasks/initialize.rb
Original file line number Diff line number Diff line change
@@ -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