Created
October 27, 2015 14:40
-
-
Save alexshires/da395ed115bf8af602ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" TEST Luigi processes """ | |
import os | |
def python_function(filename1): | |
# from filename1 create filename2 | |
if "." not in filename1: | |
print "can't split" | |
return None | |
filename2 = filename1.split(".")[0]+"_2"+filename1.split(".")[1] | |
print filename1, filename2 | |
r = os.system("cp "+filename1+" "+filename2) | |
return filename2 | |
r_func = """ | |
r_function <- function(filename2) | |
{ | |
#from filename2 create filename3 | |
} | |
""" | |
import rpy2 | |
from rpy2 import robjects | |
import luigi | |
class Task1(luigi.Task): | |
filename = luigi.Parameter() | |
def run(): | |
python_function(self.filename) | |
def output(): | |
#how to specify filename2???? | |
class Task2(luigi.Task) | |
filename1 = luigi.Parameter() | |
filename2 = None | |
def requires(): | |
self.filename2 = Task1(self.filename1) | |
def run(): | |
robjects.r[] #process R code to createe filename 3 | |
def output: | |
#How to specify filename3??? | |
if __name__ == '__main__': | |
luigi.run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, so the output function should just return 'luigi.LocalTarget(filename)', where the filename is whatever you want the output to be called. Luigi will check if the file exists and only do he next task if it does. Not sure that answers your question?