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 test_change_logger_resets_logger(self): from foundations_internal.pipeline import Pipeline new_pipeline = Pipeline(self._pipeline_context) with self._context.change_pipeline(new_pipeline): pass self.assertEqual(self._pipeline, self._context.pipeline())
class TestJob(unittest.TestCase): 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 test_run_saves_provenance_run_data(self): job = Job(self._stage, hello='world') job.run() self.assertEqual(self._context.provenance.job_run_data, {'hello': 'world'}) def test_run_saves_provenance_run_data_different_data(self): job = Job(self._stage, layers=99, neurons_per_layer=9999) job.run() self.assertEqual(self._context.provenance.job_run_data, { 'layers': 99, 'neurons_per_layer': 9999 }) def _method(self, **kwargs): pass
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 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)
def foundations_context(self): from foundations_internal.pipeline import Pipeline from foundations_internal.foundations_context import FoundationsContext pipeline = Pipeline(self.pipeline_context) context = FoundationsContext(pipeline) return self.patch( 'foundations_contrib.global_state.foundations_context', context)
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 current_foundations_context_instance(self): from foundations_internal.pipeline import Pipeline from foundations_internal.foundations_context import FoundationsContext _pipeline = Pipeline(self.pipeline_context) foundations_context = FoundationsContext(_pipeline) self.current_foundations_context.return_value = foundations_context return foundations_context
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): 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())
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
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 pipeline(self): from foundations_internal.pipeline import Pipeline return Pipeline(self.pipeline_context)