Example #1
0
File: java2.py Project: jepst/ciel
    def build_task_descriptor(cls, task_descriptor, parent_task_record, jar_lib=None, args=None, class_name=None, object_ref=None, n_outputs=1, is_tail_spawn=False, **kwargs):
        # More good stuff goes here.
        if jar_lib is None and kwargs.get("process_record_id", None) is None:
            raise BlameUserException("All Java2 invocations must either specify jar libs or an existing process ID")
        if class_name is None and object_ref is None and kwargs.get("process_record_id", None) is None:
            raise BlameUserException("All Java2 invocations must specify either a class_name or an object_ref, or else give a process ID")
        
        if jar_lib is not None:
            task_descriptor["task_private"]["jar_lib"] = jar_lib
            for jar_ref in jar_lib:
                task_descriptor["dependencies"].append(jar_ref)

        if not is_tail_spawn:
            sha = hashlib.sha1()
            hash_update_with_structure(sha, [args, n_outputs])
            hash_update_with_structure(sha, class_name)
            hash_update_with_structure(sha, object_ref)
            hash_update_with_structure(sha, jar_lib)
            name_prefix = "java2:%s:" % (sha.hexdigest())
            task_descriptor["expected_outputs"] = ["%s%d" % (name_prefix, i) for i in range(n_outputs)]            
        
        if class_name is not None:
            task_descriptor["task_private"]["class_name"] = class_name
        if object_ref is not None:
            task_descriptor["task_private"]["object_ref"] = object_ref
            task_descriptor["dependencies"].append(object_ref)
        if args is not None:
            task_descriptor["task_private"]["args"] = args
        add_package_dep(parent_task_record.package_ref, task_descriptor)
        
        return ProcExecutor.build_task_descriptor(task_descriptor, parent_task_record, n_extra_outputs=0, is_tail_spawn=is_tail_spawn, accept_ref_list_for_single=True, **kwargs)
Example #2
0
    def build_task_descriptor(cls, task_descriptor, parent_task_record, jar_lib=None, args=None, class_name=None, object_ref=None, n_outputs=1, is_tail_spawn=False, **kwargs):
        # More good stuff goes here.
        if jar_lib is None and kwargs.get("process_record_id", None) is None:
            raise BlameUserException("All Java2 invocations must either specify jar libs or an existing process ID")
        if class_name is None and object_ref is None and kwargs.get("process_record_id", None) is None:
            raise BlameUserException("All Java2 invocations must specify either a class_name or an object_ref, or else give a process ID")
        
        if jar_lib is not None:
            task_descriptor["task_private"]["jar_lib"] = jar_lib
            for jar_ref in jar_lib:
                task_descriptor["dependencies"].append(jar_ref)

        if not is_tail_spawn:
            sha = hashlib.sha1()
            hash_update_with_structure(sha, [args, n_outputs])
            hash_update_with_structure(sha, class_name)
            hash_update_with_structure(sha, object_ref)
            hash_update_with_structure(sha, jar_lib)
            name_prefix = "java2:%s:" % (sha.hexdigest())
            task_descriptor["expected_outputs"] = ["%s%d" % (name_prefix, i) for i in range(n_outputs)]            
        
        if class_name is not None:
            task_descriptor["task_private"]["class_name"] = class_name
        if object_ref is not None:
            task_descriptor["task_private"]["object_ref"] = object_ref
            task_descriptor["dependencies"].append(object_ref)
        if args is not None:
            task_descriptor["task_private"]["args"] = args
        add_package_dep(parent_task_record.package_ref, task_descriptor)
        
        return ProcExecutor.build_task_descriptor(task_descriptor, parent_task_record, n_extra_outputs=0, is_tail_spawn=is_tail_spawn, accept_ref_list_for_single=True, **kwargs)
Example #3
0
    def build_task_descriptor(cls,
                              task_descriptor,
                              parent_task_record,
                              sw_file_ref=None,
                              start_env=None,
                              start_args=None,
                              cont_ref=None,
                              n_extra_outputs=0,
                              is_tail_spawn=False,
                              **kwargs):

        if sw_file_ref is None and cont_ref is None:
            raise BlameUserException(
                "Skywriting tasks must specify either a continuation object or a .sw file"
            )
        if n_extra_outputs > 0:
            raise BlameUserException(
                "Skywriting can't deal with extra outputs")

        if not is_tail_spawn:
            task_descriptor["expected_outputs"] = [
                "%s:retval" % task_descriptor["task_id"]
            ]
            task_descriptor["task_private"]["ret_output"] = 0

        if cont_ref is not None:
            task_descriptor["task_private"]["cont"] = cont_ref
            task_descriptor["dependencies"].append(cont_ref)
        else:
            # External call: SW file should be started from the beginning.
            task_descriptor["task_private"]["swfile_ref"] = sw_file_ref
            task_descriptor["dependencies"].append(sw_file_ref)
            task_descriptor["task_private"]["start_env"] = start_env
            task_descriptor["task_private"]["start_args"] = start_args
        add_package_dep(parent_task_record.package_ref, task_descriptor)

        return ProcExecutor.build_task_descriptor(task_descriptor,
                                                  parent_task_record,
                                                  is_tail_spawn=is_tail_spawn,
                                                  is_fixed=False,
                                                  **kwargs)
Example #4
0
    def build_task_descriptor(cls,
                              task_descriptor,
                              parent_task_record,
                              binary,
                              fn_ref=None,
                              args=None,
                              n_outputs=1,
                              is_tail_spawn=False,
                              **kwargs):
        if binary is None:
            raise BlameUserException(
                "All Haskell invocations must specify a binary")

        if not isabs(binary):
            binary = join(expanduser("~/.cabal/bin"), binary)

        task_descriptor["task_private"]["binary"] = binary
        if fn_ref is not None:
            task_descriptor["task_private"]["fn_ref"] = fn_ref
            task_descriptor["dependencies"].append(fn_ref)

        if not is_tail_spawn:
            sha = hashlib.sha1()
            hash_update_with_structure(sha, [args, n_outputs])
            hash_update_with_structure(sha, binary)
            hash_update_with_structure(sha, fn_ref)
            name_prefix = "hsk:%s:" % (sha.hexdigest())
            task_descriptor["expected_outputs"] = [
                "%s%d" % (name_prefix, i) for i in range(n_outputs)
            ]

        if args is not None:
            task_descriptor["task_private"]["args"] = args

        return ProcExecutor.build_task_descriptor(
            task_descriptor,
            parent_task_record,
            n_extra_outputs=0,
            is_tail_spawn=is_tail_spawn,
            accept_ref_list_for_single=True,
            **kwargs)
Example #5
0
    def build_task_descriptor(cls, task_descriptor, parent_task_record, binary, fn_ref=None, args=None, n_outputs=1, is_tail_spawn=False, **kwargs):
        if binary is None:
            raise BlameUserException("All OCaml invocations must specify a binary")
        
        task_descriptor["task_private"]["binary"] = binary
        if fn_ref is not None:
            task_descriptor["task_private"]["fn_ref"] = fn_ref
            task_descriptor["dependencies"].append(fn_ref)

        if not is_tail_spawn:
            sha = hashlib.sha1()
            hash_update_with_structure(sha, [args, n_outputs])
            hash_update_with_structure(sha, binary)
            hash_update_with_structure(sha, fn_ref)
            name_prefix = "ocaml:%s:" % (sha.hexdigest())
            task_descriptor["expected_outputs"] = ["%s%d" % (name_prefix, i) for i in range(n_outputs)]            
        
        if args is not None:
            task_descriptor["task_private"]["args"] = args
        
        return ProcExecutor.build_task_descriptor(task_descriptor, parent_task_record, n_extra_outputs=0, is_tail_spawn=is_tail_spawn, is_fixed=False, accept_ref_list_for_single=True, **kwargs)
Example #6
0
    def build_task_descriptor(cls, task_descriptor, parent_task_record, sw_file_ref=None, start_env=None, start_args=None, cont_ref=None, n_extra_outputs=0, is_tail_spawn=False, **kwargs):

        if sw_file_ref is None and cont_ref is None:
            raise BlameUserException("Skywriting tasks must specify either a continuation object or a .sw file")
        if n_extra_outputs > 0:
            raise BlameUserException("Skywriting can't deal with extra outputs")

        if not is_tail_spawn:
            task_descriptor["expected_outputs"] = ["%s:retval" % task_descriptor["task_id"]]
            task_descriptor["task_private"]["ret_output"] = 0

        if cont_ref is not None:
            task_descriptor["task_private"]["cont"] = cont_ref
            task_descriptor["dependencies"].append(cont_ref)
        else:
            # External call: SW file should be started from the beginning.
            task_descriptor["task_private"]["swfile_ref"] = sw_file_ref
            task_descriptor["dependencies"].append(sw_file_ref)
            task_descriptor["task_private"]["start_env"] = start_env
            task_descriptor["task_private"]["start_args"] = start_args
        add_package_dep(parent_task_record.package_ref, task_descriptor)
        
        return ProcExecutor.build_task_descriptor(task_descriptor, parent_task_record, 
                                                  is_tail_spawn=is_tail_spawn, is_fixed=False, **kwargs)
Example #7
0
File: java2.py Project: jepst/ciel
 def __init__(self, worker):
     ProcExecutor.__init__(self, worker)
Example #8
0
 def __init__(self, worker):
     ProcExecutor.__init__(self, worker)