# Path: datapackage_pipelines/specs/parsers/base_parser.py
# class PipelineSpec(object):
#     def __init__(self,
#                  path=None,
#                  pipeline_id=None,
#                  pipeline_details=None,
#                  source_details=None,
#                  validation_errors=None,
#                  dependencies=None,
#                  cache_hash='',
#                  schedule=None,
#                  environment=None):
#         self.path = path
#         self.pipeline_id = pipeline_id
#         self.pipeline_details = pipeline_details
#         self.source_details = source_details
#         self.validation_errors = [] if validation_errors is None else validation_errors
#         self.dependencies = [] if dependencies is None else dependencies
#         self.cache_hash = cache_hash
#         self.schedule = schedule
#         self.environment = environment
# 
#     def __str__(self):
#         return 'PipelineSpec({}, validation_errors={}, ' \
#                'dependencies={}, cache_hash={})'\
#             .format(self.pipeline_id, self.validation_errors,
#                     self.dependencies, self.cache_hash)
# 
#     def __repr__(self):
#         return str(self)
# 
# Path: datapackage_pipelines/specs/errors.py
# class SpecError(NamedTuple):
#     short_msg: str
#     long_msg: str
# 
#     def __str__(self):
#         return '{}: {}'.format(self.short_msg, self.long_msg)


import datapackage
from datapackage.exceptions import DataPackageException
from ..parsers.base_parser import PipelineSpec
from ..errors import SpecError



class DependencyMissingException(Exception):

    def __init__(self, spec, missing):
        self.spec = spec
        self.missing = missing


def resolve_dependencies(spec: PipelineSpec, all_pipeline_ids, status_mgr):

    cache_hash = ''
    dependencies = spec.pipeline_details.get('dependencies', ())
    for dependency in dependencies:
        if 'pipeline' in dependency:
            pipeline_id = dependency['pipeline']
            if pipeline_id not in all_pipeline_ids:
                raise DependencyMissingException(spec, pipeline_id)

    for dependency in dependencies:
        if 'pipeline' in dependency:
            pipeline_id = dependency['pipeline']
            ps = status_mgr.get(pipeline_id)
            if not ps.runnable():
                spec.validation_errors.append(

# Path: datapackage_pipelines/specs/parsers/base_parser.py
# class PipelineSpec(object):
#     def __init__(self,
#                  path=None,
#                  pipeline_id=None,
#                  pipeline_details=None,
#                  source_details=None,
#                  validation_errors=None,
#                  dependencies=None,
#                  cache_hash='',
#                  schedule=None,
#                  environment=None):
#         self.path = path
#         self.pipeline_id = pipeline_id
#         self.pipeline_details = pipeline_details
#         self.source_details = source_details
#         self.validation_errors = [] if validation_errors is None else validation_errors
#         self.dependencies = [] if dependencies is None else dependencies
#         self.cache_hash = cache_hash
#         self.schedule = schedule
#         self.environment = environment
# 
#     def __str__(self):
#         return 'PipelineSpec({}, validation_errors={}, ' \
#                'dependencies={}, cache_hash={})'\
#             .format(self.pipeline_id, self.validation_errors,
#                     self.dependencies, self.cache_hash)
# 
#     def __repr__(self):
#         return str(self)
# 
# Path: datapackage_pipelines/specs/errors.py
# class SpecError(NamedTuple):
#     short_msg: str
#     long_msg: str
# 
#     def __str__(self):
#         return '{}: {}'.format(self.short_msg, self.long_msg)


# Path: datapackage_pipelines/specs/hashers/dependency_resolver.py
import datapackage
from datapackage.exceptions import DataPackageException
from ..parsers.base_parser import PipelineSpec
from ..errors import SpecError




class DependencyMissingException(Exception):

    def __init__(self, spec, missing):
        self.spec = spec
        self.missing = missing


def resolve_dependencies(spec: PipelineSpec, all_pipeline_ids, status_mgr):

    cache_hash = ''
    dependencies = spec.pipeline_details.get('dependencies', ())
    for dependency in dependencies:
        if 'pipeline' in dependency:
            pipeline_id = dependency['pipeline']
            if pipeline_id not in all_pipeline_ids:
                raise DependencyMissingException(spec, pipeline_id)

    for dependency in dependencies:
        if 'pipeline' in dependency:
            pipeline_id = dependency['pipeline']
            ps = status_mgr.get(pipeline_id)
            if not ps.runnable():
                spec.validation_errors.append(

                    SpecError('Invalid dependency',