def launch_step( self, step_handler_context: StepHandlerContext) -> List[DagsterEvent]: client = self._get_client() step_image = (step_handler_context.execute_step_args.pipeline_origin. repository_origin.container_image) if not step_image: step_image = self._image if not step_image: raise Exception( "No docker image specified by the executor config or repository" ) validate_docker_image(step_image) try: step_container = self._create_step_container( client, step_image, step_handler_context.execute_step_args) except docker.errors.ImageNotFound: client.images.pull(step_image) step_container = self._create_step_container( client, step_image, step_handler_context.execute_step_args) if len(self._networks) > 1: for network_name in self._networks[1:]: network = client.networks.get(network_name) network.connect(step_container) assert (len( step_handler_context.execute_step_args.step_keys_to_execute) == 1 ), "Launching multiple steps is not currently supported" step_key = step_handler_context.execute_step_args.step_keys_to_execute[ 0] events = [ DagsterEvent( event_type_value=DagsterEventType.ENGINE_EVENT.value, pipeline_name=step_handler_context.execute_step_args. pipeline_origin.pipeline_name, step_key=step_key, message="Launching step in Docker container", event_specific_data=EngineEventData([ EventMetadataEntry.text(step_key, "Step key"), EventMetadataEntry.text(step_container.id, "Docker container id"), ], ), ) ] step_container.start() return events
def _get_docker_image(self, pipeline_code_origin): docker_image = pipeline_code_origin.repository_origin.container_image if not docker_image: docker_image = self.image if not docker_image: raise Exception( "No docker image specified by the instance config or repository" ) validate_docker_image(docker_image) return docker_image