예제 #1
0
파일: runner.py 프로젝트: ntijanic/pdl
def make_client(project, **kwargs):
    if project.context.get('docker_client_class'):
        cls = import_name(project.context.get('docker_client_class'))
        return cls(project, **kwargs)

    args = {'base_url': project.docker_daemon_url,
            'version': project.docker_protocol_version}
    args.update(kwargs)
    docker_client = docker.Client(**args)
    return docker_client
예제 #2
0
파일: executor.py 프로젝트: ntijanic/pdl
 def exec_wrapper_job(self, job):
     cls = import_name(job.wrapper_id)
     try:
         wrp = cls(inputs=job.resolved_args.pop('$inputs', {}),
                   params=job.resolved_args.pop('$params', {}),
                   context=job.context,
                   resources=job.resources)
         result = wrp(job.resolved_args.pop('$method', None), job.resolved_args)
     except (ValidationError, ProtocolError):
         raise
     except Exception as e:
         msg = get_exception_message(e)
         logging.exception('Job failed: %s', msg)
         raise JobError(msg)
     return result if result is not None else Outputs(wrp.outputs.__json__())
예제 #3
0
파일: cli.py 프로젝트: ntijanic/pdl
def get_wrapper_schemas(package=None):
    group = 'pypdl.wrappers'
    map_id_class = {}
    classname = lambda wrp_cls: '.'.join([wrp_cls.__module__, wrp_cls.__name__])
    if package:
        pkg = import_name(package)
        for var in dir(pkg):
            obj = getattr(pkg, var)
            if isinstance(obj, type) and issubclass(obj, Wrapper):
                map_id_class[classname(obj)] = obj

    for entry_point in pkg_resources.iter_entry_points(group=group):
        wrp_cls = entry_point.load()
        full_class_name = classname(wrp_cls)
        map_id_class[full_class_name] = wrp_cls
    return [dict(schema=v._get_schema(), wrapper_id=k) for k, v in map_id_class.iteritems()]