def get_external_origin(self): """ Hack! Inject origin that the k8s images will use. The BK image uses a different directory structure (/workdir/python_modules/dagster-test/dagster_test/test_project) than the images inside the kind cluster (/dagster_test/test_project). As a result the normal origin won't work, we need to inject this one. """ return ExternalPipelineOrigin( external_repository_origin=ExternalRepositoryOrigin( repository_location_origin=InProcessRepositoryLocationOrigin( recon_repo=ReconstructableRepository( pointer=FileCodePointer( python_file= "/dagster_test/test_project/test_pipelines/repo.py", fn_name="define_demo_execution_repo", ), container_image=self._container_image, executable_path="python", entry_point=DEFAULT_DAGSTER_ENTRY_POINT, )), repository_name="demo_execution_repo", ), pipeline_name=self._pipeline_index.name, )
def test_queued_pipeline_origin_check(): code_pointer = ModuleCodePointer("fake", "fake") fake_pipeline_origin = ExternalPipelineOrigin( ExternalRepositoryOrigin( InProcessRepositoryLocationOrigin( ReconstructableRepository(code_pointer)), "foo_repo", ), "foo", ) fake_code_origin = PipelinePythonOrigin( pipeline_name="foo", repository_origin=RepositoryPythonOrigin( sys.executable, code_pointer, ), ) PipelineRun( status=PipelineRunStatus.QUEUED, external_pipeline_origin=fake_pipeline_origin, pipeline_code_origin=fake_code_origin, ) with pytest.raises(check.CheckError): PipelineRun(status=PipelineRunStatus.QUEUED) with pytest.raises(check.CheckError): PipelineRun().with_status(PipelineRunStatus.QUEUED)
def create_invalid_run(instance, **kwargs): create_run_for_test( instance, external_pipeline_origin=ExternalPipelineOrigin( ExternalRepositoryOrigin( InProcessRepositoryLocationOrigin( ReconstructableRepository(ModuleCodePointer( "fake", "fake"))), "foo", ), "wrong-pipeline", ), pipeline_name="wrong-pipeline", **kwargs, )
def test_queued_pipeline_origin_check(): fake_pipeline_origin = ExternalPipelineOrigin( ExternalRepositoryOrigin( InProcessRepositoryLocationOrigin( ReconstructableRepository(ModuleCodePointer("fake", "fake"))), "foo_repo", ), "foo", ) PipelineRun(status=PipelineRunStatus.QUEUED, external_pipeline_origin=fake_pipeline_origin) with pytest.raises(check.CheckError): PipelineRun(status=PipelineRunStatus.QUEUED) with pytest.raises(check.CheckError): PipelineRun().with_status(PipelineRunStatus.QUEUED)