当前位置: 首页>>代码示例>>Python>>正文


Python ProcessUnit.execute方法代码示例

本文整理汇总了Python中cwsl.core.process_unit.ProcessUnit.execute方法的典型用法代码示例。如果您正苦于以下问题:Python ProcessUnit.execute方法的具体用法?Python ProcessUnit.execute怎么用?Python ProcessUnit.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cwsl.core.process_unit.ProcessUnit的用法示例。


在下文中一共展示了ProcessUnit.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        # Required input
        future_dataset = self.getInputFromPort("future_dataset")
        baseline_dataset = self.getInputFromPort("baseline_dataset")

        # Execute the process.
        new_constraints = [Constraint('change_type', ['abs-change'])]
        this_process = ProcessUnit([future_dataset, baseline_dataset],
                                   self.out_pattern,
                                   self.command,
                                   extra_constraints=new_constraints,
                                   execution_options=self._execution_options,
                                   map_dict={'fut_start': ('year_start', 0),
                                             'fut_end': ('year_end', 0),
                                             'hist_start': ('year_start', 1),
                                             'hist_end': ('year_end', 1)})

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception as e:
            raise vistrails_module.ModuleError(self, e.output)

        process_output = this_process.file_creator
        self.setResult('out_dataset', process_output)
开发者ID:AimeeSlangen,项目名称:cwsl-mas,代码行数:27,代码来源:change.py

示例2: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort('in_dataset')
        west_lon = self.getInputFromPort('west_lon')
        east_lon = self.getInputFromPort('east_lon')
        south_lat = self.getInputFromPort('south_lat')
        north_lat = self.getInputFromPort('north_lat')

        self.positional_args = [('west_lon', 0),
                                ('east_lon', 1),
                                ('south_lat', 2),
                                ('north_lat', 3)]
        self.keyword_args = {}

        new_constraints_for_output = set([Constraint('west_lon', [west_lon]),
                                          Constraint('east_lon', [east_lon]),
                                          Constraint('south_lat', [south_lat],
                                          Constraint('north_lat', [north_lat]))
                                          ])
        
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   new_constraints_for_output,
                                   execution_options=self._execution_options,
                                   positional_args=self.positional_args,
                                   cons_keywords=self.keyword_args)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except subprocess.CalledProcessError, e:
            raise vistrails_module.ModuleError(self, e.output)
开发者ID:taerwin,项目名称:cwsl-sandbox,代码行数:34,代码来源:vt_sellonlatbox.py

示例3: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort("in_dataset")
        method = self.getInputFromPort("method")

        self.positional_args = [(method, 0, "raw")]
        self.keyword_args = {}

        if len(method.split(",")) > 1:
            agg_constraint = "".join(method.split(","))
        else:
            agg_constraint = method

        new_constraints_for_output = set([Constraint("latagg_info", [agg_constraint]), Constraint("suffix", ["nc"])])

        this_process = ProcessUnit(
            [in_dataset],
            self.out_pattern,
            self.command,
            new_constraints_for_output,
            execution_options=self._execution_options,
            positional_args=self.positional_args,
            cons_keywords=self.keyword_args,
        )

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception as e:
            raise vistrails_module.ModuleError(self, repr(e))

        process_output = this_process.file_creator

        self.setResult("out_dataset", process_output)
开发者ID:PamMichael,项目名称:cwsl-mas,代码行数:35,代码来源:vt_meridional_agg.py

示例4: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort('in_dataset')
        method = self.getInputFromPort('method')

        self.positional_args = [(method, 0, 'raw'), ]
        self.keyword_args = {}

        if len(method.split(',')) > 1:
            agg_constraint = "".join(method.split(','))
        else:
            agg_constraint = method

        new_constraints_for_output = set([Constraint('timeagg_info', [agg_constraint]),
                                          Constraint('suffix', ['nc']),
                                          ])
        
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   new_constraints_for_output,
                                   execution_options=self._execution_options,
                                   positional_args=self.positional_args,
                                   cons_keywords=self.keyword_args)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception as e:
            raise vistrails_module.ModuleError(self, repr(e))
            
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:rensa,项目名称:cwsl-mas,代码行数:35,代码来源:vt_3dat.py

示例5: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        # Required input
        in_dataset = self.getInputFromPort("in_dataset")
        year_start = self.getInputFromPort("year_start")
        year_end = self.getInputFromPort("year_end")
        seas_agg = self.getInputFromPort("seas_agg")

        new_cons = set([Constraint('year_start', [year_start]),
                        Constraint('year_end', [year_end]),
                        Constraint('seas_agg', [seas_agg]),
                        Constraint('suffix', ['nc']),
                        Constraint('grid', ['native'])])

        # Optional added constraints.
        try:
            # Add extra constraints if necessary.
            added_constraints = self.getInputFromPort('added_constraints')
            cons_for_output = new_cons.intersection(added_constraints)
        except vistrails_module.ModuleError:
            cons_for_output = new_cons

        #self.command = self.command + ' tos tos ' + year_start + ' ' + year_end + ' ' + seas_agg
        # Execute the seas_vars process.
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   cons_for_output,
                                   positional_args=self.positional_args,
                                   execution_options=self._execution_options)

        this_process.execute(simulate=configuration.simulate_execution)
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:ScottWales,项目名称:cwsl-mas,代码行数:37,代码来源:vt_seas_vars.py

示例6: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort('in_dataset')
        try:
            # Add extra constraints if necessary.
            added_constraints = self.getInputFromPort('added_constraints')
        except vistrails_module.ModuleError:
            added_constraints = None


        command = self.getInputFromPort("command")
        output_pattern = self.getInputFromPort("output_pattern")

        cons_for_output = set()
        if added_constraints:
            cons_for_output = set.union(cons_for_output,
                                        set(added_constraints))

        # Do the stuff.
        this_process = ProcessUnit([in_dataset],
                                   self.output_pattern,
                                   command,
                                   cons_for_output)

        this_process.execute(simulate=configuration.simulate_execution)
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
        self.setResult('out_constraints', str(process_output.constraints))

        # Unload the modules at the end.
        self.module_loader.unload(self.required_modules)
开发者ID:AimeeSlangen,项目名称:cwsl-mas,代码行数:34,代码来源:vt_general_command_pattern.py

示例7: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset1 = self.getInputFromPort('in_dataset1')
        in_dataset2 = self.getInputFromPort('in_dataset2')

        self.positional_args = []
        self.keyword_args = {}

        new_constraints_for_output = set([Constraint('extra_info', ['fldcor']),
                                          Constraint('suffix', ['nc'])])

        merge_val =  self.getInputFromPort('merge_constraints')
        if merge_val:
            extra_merge = [cons_name.strip() for cons_name in merge_val.split(',')]
        else:
            extra_merge = []
        
        this_process = ProcessUnit([in_dataset1, in_dataset2],
                                   self.out_pattern,
                                   self.command,
                                   new_constraints_for_output,
                                   execution_options=self._execution_options,
                                   positional_args=self.positional_args,
                                   cons_keywords=self.keyword_args,
                                   merge_output=extra_merge)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception as e:
            raise vistrails_module.ModuleError(self, repr(e))
            
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:AimeeSlangen,项目名称:cwsl-mas,代码行数:36,代码来源:vt_fldcor.py

示例8: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset1 = self.getInputFromPort('in_dataset1')
        in_dataset2 = self.getInputFromPort('in_dataset2')
        operation = self.getInputFromPort('operation')

        self.positional_args = [(operation, 0, 'raw'), ]
        self.keyword_args = {}

        new_constraints_for_output = set([Constraint('extra_info', [operation]),
                                          Constraint('suffix', ['nc']),
                                          ])
        
        this_process = ProcessUnit([in_dataset1, in_dataset2],
                                   self.out_pattern,
                                   self.command,
                                   new_constraints_for_output,
                                   execution_options=self._execution_options,
                                   positional_args=self.positional_args,
                                   cons_keywords=self.keyword_args,
                                   merge_output=['model', 'institute'])

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception as e:
            raise vistrails_module.ModuleError(self, repr(e))
            
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:AimeeSlangen,项目名称:cwsl-mas,代码行数:32,代码来源:vt_dataset_arithmetic.py

示例9: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort('cod_dataset')

        command = "${CWSL_CTOOLS}/sdm/sdmrun.py"

        sdm_config = configuration.cwsl_ctools_path + "/sdm/default.cfg"
        positional_args = [("dxt-gridded", 0, "raw"),
                           ("-c " + sdm_config, 0, "raw")]
        
        # The data is written out to the default
        # location.
        output_pattern = os.path.join(configuration.user_basepath,
                                      FileCreator.default_pattern(in_dataset.constraints) + ".nc")
        this_process = ProcessUnit([in_dataset],
                                   output_pattern,
                                   command,
                                   in_dataset.constraints,
                                   execution_options=self._required_modules,
                                   positional_args=positional_args)

        this_process.execute(simulate=configuration.simulate_execution)
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:CWSL,项目名称:cwsl-mas,代码行数:27,代码来源:sdm_extract.py

示例10: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        # Required input
        in_dataset = self.getInputFromPort("in_dataset")
        year_start = self.getInputFromPort("start_year")
        year_end = self.getInputFromPort("end_year")
        
        new_cons = set([Constraint('year_start', [year_start]),
                        Constraint('year_end', [year_end]),
                        Constraint('suffix', ['nc']),
                        Constraint('grid', ['native'])])

        cons_for_output = new_cons

        # Execute the seas_vars process.
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   cons_for_output,
                                   positional_args=self.positional_args,
                                   cons_keywords=self.keyword_args,
                                   execution_options=self._execution_options)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception, e:
            raise vistrails_module.ModuleError(self, e.output)
开发者ID:ScottWales,项目名称:cwsl-mas,代码行数:29,代码来源:vt_xmltonc.py

示例11: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort('in_dataset')
        method = self.getInputFromPort('method')
        grid = self.getInputFromPort('grid')

        self.positional_args = [(method, 0, 'raw'), (grid, 1, 'raw'), ]
        self.keyword_args = {}
        
        grid = grid.split('/')[-1]
        if len(grid.split('.')) > 1:  # i.e. a weights file as opposed to pre-defined grid
            grid_constraint = method+'-'+grid.split('.')[0]
        else:
            grid_constraint = method+'-'+grid

        new_constraints_for_output = set([Constraint('grid_info', [grid_constraint]),
                                          Constraint('suffix', ['nc']),
                                          ])
        
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   new_constraints_for_output,
                                   execution_options=self._execution_options,
                                   positional_args=self.positional_args,
                                   cons_keywords=self.keyword_args)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception as e:
            raise vistrails_module.ModuleError(self, repr(e))
            
        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:CWSL,项目名称:cwsl-mas,代码行数:37,代码来源:vt_remap.py

示例12: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        # Required input
        in_dataset = self.getInputFromPort("in_dataset")
        variable_name = self.getInputFromPort("variable_name")
        self.positional_args=[(variable_name,0,'raw'),('model',1)]

        new_cons = set([Constraint('variable', [variable_name]),
                        Constraint('suffix', ['png']),
                        ])

        # Optional added constraints.
        try:
            # Add extra constraints if necessary.
            added_constraints = self.getInputFromPort('added_constraints')
            cons_for_output = new_cons.intersection(added_constraints)
        except vistrails_module.ModuleError:
            cons_for_output = new_cons


        # Execute the seas_vars process.
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   cons_for_output,
                                   execution_options=self._execution_options,
                                   positional_args=self.positional_args)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except Exception, e:
            raise vistrails_module.ModuleError(self, e.output)
开发者ID:ScottWales,项目名称:cwsl-mas,代码行数:34,代码来源:vt_plot_timeseries.py

示例13: test_mapping_after_passing

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def test_mapping_after_passing(self):
        """ Mapping of constraints should work if applied to the output of an earlier ProcessUnit. """

        # First create a basic process unit.
        with mock.patch('cwsl.core.pattern_dataset.PatternDataSet.glob_fs') as mock_glob:
            
            mock_glob.return_value = ['/a/fake/file/red_1986_2005_kangaroo.nc']

            first_patternds = PatternDataSet('/a/fake/file/%colour%_%start%_%end%_%animal%.nc')
            first_process = ProcessUnit([first_patternds], '/a/second/file_pattern/%colour%_%start%_%end%_%animal%.nc',
                                        'echo')
            result = first_process.execute(simulate=True)
            
            # Then take the output of that process and apply a mapping.
            second_process = ProcessUnit([result], '/a/final/pattern/%colour%_%hist_start%_%hist_end%_%animal%.txt',
                                         'echo', map_dict={'hist_start': ('start', 0),
                                                           'hist_end': ('end', 0)})

            final_out = second_process.execute(simulate=True)

            expected_string = (self.script_header + "mkdir -p /a/final/output\necho" +
                               "/a/second/file_pattern/red_1986_2005_kangaroo.nc " + 
                               "/a/final/pattern/red_1986_2005_kangaroo.nc")

            self.assertEqual(expected_string, second_process.scheduler.job.to_str())
开发者ID:ScottWales,项目名称:cwsl-mas,代码行数:27,代码来源:test_mapping.py

示例14: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        # Required input
        in_dataset = self.getInputFromPort("in_dataset")

        new_cons = set([Constraint('extra_info', ['nino34']),
                        Constraint('latsouth_info', ['5S']),
                        Constraint('latnorth_info', ['5N']),
                        Constraint('latagg_info', ['fldavg']),
                        Constraint('lonwest_info', ['190E']),
                        Constraint('loneast_info', ['240E']),
                        Constraint('lonagg_info', ['fldavg']),
                        Constraint('leveltop_info', ['surface']),
                        Constraint('levelbottom_info', ['surface']),
                        Constraint('anomaly_info', ['anom']),
                       ])
        
        # Execute the process.
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   new_cons,
                                   positional_args=self.positional_args,
                                   execution_options=self._execution_options)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except subprocess.CalledProcessError as e:
            raise vistrails_module.ModuleError(self, e.output)
        except Exception as e:
            raise vistrails_module.ModuleError(self, repr(e))

        process_output = this_process.file_creator

        self.setResult('out_dataset', process_output)
开发者ID:AimeeSlangen,项目名称:cwsl-mas,代码行数:37,代码来源:vt_nino34.py

示例15: compute

# 需要导入模块: from cwsl.core.process_unit import ProcessUnit [as 别名]
# 或者: from cwsl.core.process_unit.ProcessUnit import execute [as 别名]
    def compute(self):

        in_dataset = self.getInputFromPort('in_dataset')
        try:
            # Add extra constraints if necessary.
            added_constraints = self.getInputFromPort('added_constraints')
        except vistrails_module.ModuleError:
            added_constraints = None

        # Change the file_type constraint from nc to xml and add
        # any added constraints.
        cons_for_output = set([Constraint('suffix', ['xml'])])
        if added_constraints:
            cons_for_output = set.union(cons_for_output,
                                        set(added_constraints))


        # Execute the xml_to_nc process.
        this_process = ProcessUnit([in_dataset],
                                   self.out_pattern,
                                   self.command,
                                   cons_for_output,
                                   execution_options=self._execution_options)

        try:
            this_process.execute(simulate=configuration.simulate_execution)
        except subprocess.CalledProcessError, e:
            raise vistrails_module.ModuleError(self, e.output)
开发者ID:ScottWales,项目名称:cwsl-mas,代码行数:30,代码来源:vt_cdscan.py


注:本文中的cwsl.core.process_unit.ProcessUnit.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。