def _collect_envs(self, operation: GenericOperation, **kwargs) -> Dict: """ Collect the envs stored on the Operation and set the system-defined ELYRA_RUNTIME_ENV Note: subclasses should call their superclass (this) method first. :return: dictionary containing environment name/value pairs """ envs: Dict = operation.env_vars_as_dict(logger=self.log) envs["ELYRA_RUNTIME_ENV"] = self.name # set environment variables for Minio/S3 access, in the following order of precedence: # 1. use `cos_secret` # 2. use `cos_username` and `cos_password` if "cos_secret" in kwargs and kwargs["cos_secret"]: # ensure the AWS_ACCESS_* envs are NOT set envs.pop("AWS_ACCESS_KEY_ID", None) envs.pop("AWS_SECRET_ACCESS_KEY", None) else: # set AWS_ACCESS_KEY_ID, if defined if "cos_username" in kwargs and kwargs["cos_username"]: envs["AWS_ACCESS_KEY_ID"] = kwargs["cos_username"] else: envs.pop("AWS_ACCESS_KEY_ID", None) # set AWS_SECRET_ACCESS_KEY, if defined if "cos_password" in kwargs and kwargs["cos_password"]: envs["AWS_SECRET_ACCESS_KEY"] = kwargs["cos_password"] else: envs.pop("AWS_SECRET_ACCESS_KEY", None) # Convey pipeline logging enablement to operation envs["ELYRA_ENABLE_PIPELINE_INFO"] = str(self.enable_pipeline_info) return envs
def test_env_list_to_dict_function(): env_variables = [ "KEY=value", None, "", " =empty_key", "=no_key", "EMPTY_VALUE= ", "NO_VALUE=", "KEY2=value2", "TWO_EQUALS=KEY=value", "==", ] env_variables_dict = {"KEY": "value", "KEY2": "value2", "EMPTY_VALUE": " ", "TWO_EQUALS": "KEY=value"} component_parameters = { "filename": "elyra/pipeline/tests/resources/archive/test.ipynb", "env_vars": env_variables, "runtime_image": "tensorflow/tensorflow:latest", } test_operation = GenericOperation( id="test-id", type="execution-node", classifier="execute-notebook-node", name="test", component_params=component_parameters, ) assert test_operation.env_vars_as_dict() == env_variables_dict
def _collect_envs(operation: GenericOperation, elyra_run_name: str) -> Dict: envs = os.environ.copy() # Make sure this process's env is "available" in the kernel subprocess envs.update(operation.env_vars_as_dict()) envs["ELYRA_RUNTIME_ENV"] = "local" # Special case envs["ELYRA_RUN_NAME"] = elyra_run_name return envs