def test_load_artifact_from_archive_with_mock_provenance(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()
        mock_provenance = self.MockProvenance()

        pipeline_context.provenance = mock_provenance
        pipeline_context.load_artifact_from_archive(mock_archive)

        self.assertEqual(mock_archive, mock_provenance.archiver)
    def test_fill_provenance(self):
        from foundations_contrib.config_manager import ConfigManager

        self.config_manager = ConfigManager()
        pipeline_context = PipelineContext()

        self.config_manager["other_world"] = "aliens"

        pipeline_context.fill_provenance(self.config_manager)
        self.assertEqual(pipeline_context.provenance.config["other_world"], "aliens")
Beispiel #3
0
    def setUp(self):
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.pipeline import Pipeline

        self._context = PipelineContext()
        self._pipeline = Pipeline(self._context)
        self._stage = self._pipeline.stage(self._method)
    def setUp(self):
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self._pipeline = Pipeline(self._pipeline_context)
        self._context = FoundationsContext(self._pipeline)
Beispiel #5
0
    def setUp(self):
        from foundations_contrib.global_state import redis_connection
        from foundations_contrib.global_state import message_router
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.pipeline import Pipeline
        import faker

        self._redis = redis_connection
        self._redis.flushall()
        self._faker = faker.Faker()

        self._pipeline_context = PipelineContext()

        self._project_name = self._str_random_uuid()
        self._pipeline_context.provenance.project_name = self._project_name

        self._job_id = self._str_random_uuid()
        self._pipeline_context.file_name = self._job_id

        self._user = self._random_name()
        self._pipeline_context.provenance.user_name = self._user

        self._pipeline = Pipeline(self._pipeline_context)

        self._message_router = message_router
    def setUpClass(klass):
        from foundations_contrib.global_state import message_router
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext

        klass._message_router = message_router
        klass._pipeline_context = PipelineContext()
        klass._pipeline = Pipeline(klass._pipeline_context)
    def test_pipeline_context_wrapper_returns_pipeline_context(self):
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.pipeline_context_wrapper import PipelineContextWrapper

        pipeline_context = PipelineContext()
        pipeline_context_wrapper = PipelineContextWrapper(pipeline_context)
        self.assertEqual(pipeline_context,
                         pipeline_context_wrapper.pipeline_context())
Beispiel #8
0
    def set_up(self):
        import fakeredis
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self._pipeline = Pipeline(self._pipeline_context)
        self.patch('foundations_rest_api.global_state.redis_connection',
                   fakeredis.FakeRedis())
Beispiel #9
0
def _create_foundations_context():
    from foundations_internal.pipeline_context import PipelineContext
    from foundations_internal.pipeline import Pipeline
    from foundations_internal.foundations_context import FoundationsContext

    _pipeline_context = PipelineContext()
    _pipeline = Pipeline(_pipeline_context)

    return FoundationsContext(_pipeline)
    def set_up(self):
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self.mock_current_foundations_context.pipeline_context.return_value = self._pipeline_context

        self._message_router = self.MockMessageRouter()
        self._logger = GlobalMetricLogger(self._message_router)

        self._pipeline_context.file_name = None
        self._pipeline_context.provenance.project_name = self.fake_project_name
Beispiel #11
0
    def setUp(self):
        from foundations_internal.pipeline_context import PipelineContext

        self.route_name = None
        self.message = None

        self._pipeline_context = PipelineContext()
        self._pipeline_context.file_name = 'some_project'
        self._router = Mock()
        self._router.push_message.side_effect = self._push_message
        self._producer = RunJob(self._router, self._pipeline_context)
    def test_load_artifact_from_archive_fully_loaded(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()
        mock_provenance = self.MockProvenance()

        pipeline_context.mark_fully_loaded()
        pipeline_context.provenance = mock_provenance
        pipeline_context.load_artifact_from_archive(mock_archive)

        self.assertEqual(0, mock_provenance.load_artifact_counter)
Beispiel #13
0
    def set_up(self):
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self._pipeline_context.file_name = None
        self._pipeline_context.provenance.project_name = self.project_name

        self.foundations_context.pipeline_context.return_value = self._pipeline_context

        self.foundations_context.pipeline_context().provenance.annotations = (
            self.provenance_annotations)
        self.redis.flushall()
    def test_save_uses_save_method_on_result_saver(self):
        pipeline_context = PipelineContext()
        pipeline_context.file_name = self.job_id
        mock_result_saver = self.MockResultSaver()

        pipeline_context.save(mock_result_saver)
        self.assertEqual(mock_result_saver.file_name, pipeline_context.file_name)
        self.assertEqual(mock_result_saver.context, pipeline_context._context())
Beispiel #15
0
    def setUp(self):
        from foundations_internal.pipeline_context import PipelineContext

        self.route_name = None
        self.message = None

        self._pipeline_context = PipelineContext()
        self._pipeline_context.file_name = 'some_project'
        self._router = Mock()
        self._router.push_message.side_effect = self._push_message
        self._error_information = {'type': None,
                                   'exception': None, 'traceback': []}
        self._producer = FailedJob(
            self._router, self._pipeline_context, self._error_information)
Beispiel #16
0
def cleanup():
    import shutil
    from os import getcwd, remove
    from os.path import isdir
    from glob import glob
    from foundations_contrib.global_state import redis_connection, foundations_job
    from foundations_internal.pipeline_context import PipelineContext
    from foundations_internal.pipeline import Pipeline

    tmp_dir = getcwd() + '/foundations_home/job_data'
    if isdir(tmp_dir):
        shutil.rmtree(tmp_dir)

    for file in glob('*.tgz'):
        remove(file)

    pipeline_context = PipelineContext()
    pipeline = Pipeline(pipeline_context)
    foundations_job._pipeline = pipeline
Beispiel #17
0
def cleanup():
    import shutil
    from os import getcwd, remove
    from os.path import isdir
    from glob import glob
    from foundations_rest_api.global_state import redis_connection
    from foundations_contrib.global_state import foundations_context
    from foundations_internal.pipeline_context import PipelineContext
    from foundations_internal.pipeline import Pipeline

    tmp_dir = getcwd() + '/tmp'
    if isdir(tmp_dir):
        shutil.rmtree(tmp_dir)

    for file in glob('*.tgz'):
        remove(file)

    redis_connection.flushall()

    pipeline_context = PipelineContext()
    pipeline = Pipeline(pipeline_context)
    foundations_context._pipeline = pipeline
    def setUp(self):
        from foundations_contrib.config_manager import ConfigManager
        from foundations_internal.deployment_manager import DeploymentManager
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.foundations_context import FoundationsContext

        self._listing = self.MockListing()

        self._config = ConfigManager()
        self._config["deployment_implementation"] = {
            "deployment_type": self.MockDeployment
        }

        self._config["project_listing_implementation"] = {
            "project_listing_type": self._mock_listing,
        }

        self._deployment_manager = DeploymentManager(self._config)

        self._pipeline_context = PipelineContext()
        self._pipeline = Pipeline(self._pipeline_context)
        self._foundations_context = FoundationsContext(self._pipeline)
    def test_load_job_source_from_archive(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()

        pipeline_context.load_job_source_from_archive(mock_archive)
    def test_load_artifact_from_archive(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()

        pipeline_context.load_artifact_from_archive(mock_archive)
Beispiel #21
0
 def pipeline_context(self):
     from foundations_internal.pipeline_context import PipelineContext
     return PipelineContext()
 def pipeline_context(self):
     return PipelineContext()