Python luigi.IntParameter() Examples

The following are 5 code examples of luigi.IntParameter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module luigi , or try the search function .
Example #1
Source File: test_task_on_kart.py    From gokart with MIT License 5 votes vote down vote up
def test_repr(self):
        class _SubTask(gokart.TaskOnKart):
            task_namespace = __name__

        class _Task(gokart.TaskOnKart):
            task_namespace = __name__
            int_param = luigi.IntParameter()
            task_param = TaskInstanceParameter()
            list_task_param = ListTaskInstanceParameter()

        task = _Task(int_param=1, task_param=_SubTask(), list_task_param=[_SubTask(), _SubTask()])
        sub_task_id = _SubTask().make_unique_id()
        expected = f'{__name__}._Task(int_param=1, task_param={__name__}._SubTask({sub_task_id}), ' \
            f'list_task_param=[{__name__}._SubTask({sub_task_id}), {__name__}._SubTask({sub_task_id})])'
        self.assertEqual(expected, str(task)) 
Example #2
Source File: main.py    From d6tflow with MIT License 5 votes vote down vote up
def test_params(cleanup):
    class TaskParam(d6tflow.tasks.TaskCache):
        nrows = luigi.IntParameter(default=10)
        def run(self):
            self.save(pd.DataFrame({'a':range(self.nrows)}))

    t1 = TaskParam(); t2 = TaskParam(nrows=20);
    assert not t1.complete(); assert not t2.complete();

    t1.run()
    assert t1.complete(); assert not t2.complete(); 
Example #3
Source File: test_export.py    From d6tflow with MIT License 5 votes vote down vote up
def test_task(self,cleanup):

        e = d6tflow.pipes.FlowExport('utest-flowexport',tasks=Task1All(),write_dir=cfg_write_dir)
        e.generate()

        code = readfile(e.write_dir/e.write_filename_tasks)
        assert code == '''
import d6tflow
import luigi
import datetime

class Task1All(d6tflow.tasks.TaskCache):
    external=True
    persist=['data']
    idx=luigi.parameter.IntParameter(default=1)
    idx2=luigi.parameter.Parameter(default='test')
    idx3=luigi.parameter.Parameter(default='test3')

'''

        code = readfile(e.write_dir/e.write_filename_run)
        assert code == '''
# shared d6tflow workflow, see https://d6tflow.readthedocs.io/en/latest/collaborate.html
import d6tflow.pipes
import tasks_d6tpipe
import datetime

d6tflow.pipes.init('utest-flowexport',profile='default') # to customize see https://d6tflow.readthedocs.io/en/latest/d6tflow.html#d6tflow.pipes.init
d6tflow.pipes.get_pipe('utest-flowexport').pull()

# task output is loaded below, for more details see https://d6tflow.readthedocs.io/en/latest/tasks.html#load-output-data
df_task1all = tasks_d6tpipe.Task1All(idx=1, idx2='test', idx3='test3', ).outputLoad()
''' 
Example #4
Source File: test_export.py    From d6tflow with MIT License 5 votes vote down vote up
def test_task2(self,cleanup):

        e = d6tflow.pipes.FlowExport('utest-flowexport',tasks=[Task1A(),Task1All()],write_dir=cfg_write_dir)
        e.generate()

        code = readfile(e.write_dir/e.write_filename_tasks)
        assert code == '''
import d6tflow
import luigi
import datetime

class Task1All(d6tflow.tasks.TaskCache):
    external=True
    persist=['data']
    idx=luigi.parameter.IntParameter(default=1)
    idx2=luigi.parameter.Parameter(default='test')
    idx3=luigi.parameter.Parameter(default='test3')

class Task1A(d6tflow.tasks.TaskCache):
    external=True
    persist=['df', 'df2']
    idx=luigi.parameter.IntParameter(default=1)
    idx2=luigi.parameter.Parameter(default='test')

'''

        code = readfile(e.write_dir/e.write_filename_run)
        assert code == '''
# shared d6tflow workflow, see https://d6tflow.readthedocs.io/en/latest/collaborate.html
import d6tflow.pipes
import tasks_d6tpipe
import datetime

d6tflow.pipes.init('utest-flowexport',profile='default') # to customize see https://d6tflow.readthedocs.io/en/latest/d6tflow.html#d6tflow.pipes.init
d6tflow.pipes.get_pipe('utest-flowexport').pull()

# task output is loaded below, for more details see https://d6tflow.readthedocs.io/en/latest/tasks.html#load-output-data
df_task1all = tasks_d6tpipe.Task1All(idx=1, idx2='test', idx3='test3', ).outputLoad()
df_task1a_df, df_task1a_df2, = tasks_d6tpipe.Task1A(idx=1, idx2='test', ).outputLoad()
''' 
Example #5
Source File: test_export.py    From d6tflow with MIT License 4 votes vote down vote up
def test_flow(self,cleanup):

        e = d6tflow.pipes.FlowExport('utest-flowexport',flows=Task1All(),write_dir=cfg_write_dir)
        e.generate()

        code = readfile(e.write_dir/e.write_filename_tasks)
        assert code == '''
import d6tflow
import luigi
import datetime

class Task1A(d6tflow.tasks.TaskCache):
    external=True
    persist=['df', 'df2']
    idx=luigi.parameter.IntParameter(default=1)
    idx2=luigi.parameter.Parameter(default='test')

class Task1B(d6tflow.tasks.TaskCache):
    external=True
    persist=['df', 'df2']
    idx3=luigi.parameter.Parameter(default='test3')

class Task1All(d6tflow.tasks.TaskCache):
    external=True
    persist=['data']
    idx=luigi.parameter.IntParameter(default=1)
    idx2=luigi.parameter.Parameter(default='test')
    idx3=luigi.parameter.Parameter(default='test3')

'''

        code = readfile(e.write_dir/e.write_filename_run)
        assert code == '''
# shared d6tflow workflow, see https://d6tflow.readthedocs.io/en/latest/collaborate.html
import d6tflow.pipes
import tasks_d6tpipe
import datetime

d6tflow.pipes.init('utest-flowexport',profile='default') # to customize see https://d6tflow.readthedocs.io/en/latest/d6tflow.html#d6tflow.pipes.init
d6tflow.pipes.get_pipe('utest-flowexport').pull()

# task output is loaded below, for more details see https://d6tflow.readthedocs.io/en/latest/tasks.html#load-output-data
df_task1a_df, df_task1a_df2, = tasks_d6tpipe.Task1A(idx=1, idx2='test', ).outputLoad()
df_task1b_df, df_task1b_df2, = tasks_d6tpipe.Task1B(idx3='test3', ).outputLoad()
df_task1all = tasks_d6tpipe.Task1All(idx=1, idx2='test', idx3='test3', ).outputLoad()
'''