def deploy(project_name, entrypoint, params): import os import os.path as path import json from foundations_contrib.job_deployer import deploy_job from foundations_contrib.global_state import ( current_foundations_job, redis_connection, config_manager, ) if project_name is None: project_name = path.basename(os.getcwd()) job = current_foundations_job() job.project_name = project_name config_manager["run_script_environment"] = { "script_to_run": entrypoint, "enable_stages": False, } job.user_name = (_get_user_name_from_token()) if params is not None: with open("foundations_job_parameters.json", "w+") as params_file: json.dump(params, params_file) return deploy_job(job, None, {})
def deploy(project_name, entrypoint, params): import os import os.path as path import json from foundations_contrib.job_deployer import deploy_job from foundations_contrib.global_state import ( current_foundations_context, redis_connection, config_manager, ) from foundations_internal.pipeline_context_wrapper import PipelineContextWrapper if project_name is None: project_name = path.basename(os.getcwd()) current_foundations_context().set_project_name(project_name) config_manager["run_script_environment"] = { "script_to_run": entrypoint, "enable_stages": False, } current_foundations_context().pipeline_context().provenance.user_name = ( _get_user_name_from_token() ) pipeline_context_wrapper = PipelineContextWrapper( current_foundations_context().pipeline_context() ) if params is not None: with open("foundations_job_parameters.json", "w+") as params_file: json.dump(params, params_file) return deploy_job(pipeline_context_wrapper, None, {})
def test_job_deployer_returns_deployment_wrapper(self): from foundations_contrib.deployment_wrapper import DeploymentWrapper job_deployment = deploy_job(self.fake_pipeline_context_wrapper, self.fake_job_name, self.fake_job_params) self.assertIsInstance(job_deployment, DeploymentWrapper)
def test_job_deployer_returns_job_deployment_with_same_job_name_as_was_passed_in( self): job_deployment = deploy_job(self.fake_pipeline_context_wrapper, self.fake_job_name, self.fake_job_params) self.assertEqual(self.fake_job_name, job_deployment.job_name())
def test_job_deployer_logs_job_deploying_message(self): deploy_job(self.fake_pipeline_context_wrapper, self.fake_job_name, self.fake_job_params) self.mock_logger.info.assert_called_with( 'Job submission started. Ctrl-C to cancel.')
def test_job_deployer_returns_job_deployment_with_same_job_name_as_was_passed_in( self): job_deployment = deploy_job(self.fake_foundations_job, self.fake_job_name, self.fake_job_params) self.assertEqual(self.fake_job_name, job_deployment.job_name())
def test_job_deployer_logs_job_deploying_message(self): deploy_job(self.fake_foundations_job, self.fake_job_name, self.fake_job_params) self.mock_logger.info.assert_called_with( 'Job submission started. Ctrl-C to cancel.')