Esempio n. 1
0
    def auto(cls,
             config_file: typing.Union[str, ConfigFile] = None,
             img_name: Optional[str] = None) -> ImageConfig:
        """
        Reads from config file or from img_name
        :param config_file:
        :param img_name:
        :return:
        """
        if config_file is None and img_name is None:
            raise ValueError(
                "Either an image or a config with a default image should be provided"
            )

        default_img = Image.look_up_image_info("default",
                                               img_name) if img_name else None

        other_images = []
        if config_file:
            config_file = get_config_file(config_file)
            other_images = [
                Image.look_up_image_info(k, tag=v, optional_tag=True) for k, v
                in _internal.Images.get_specified_images(config_file).items()
            ]
        return cls.create_from(default_img, other_images)
Esempio n. 2
0
 def auto(cls,
          config_file: typing.Union[str, ConfigFile] = None) -> DataConfig:
     config_file = get_config_file(config_file)
     return DataConfig(
         s3=S3Config.auto(config_file),
         gcs=GCSConfig.auto(config_file),
     )
Esempio n. 3
0
 def auto(self,
          config_file: typing.Union[str, ConfigFile] = None) -> GCSConfig:
     config_file = get_config_file(config_file)
     kwargs = {}
     kwargs = set_if_exists(
         kwargs, "gsutil_parallelism",
         _internal.GCP.GSUTIL_PARALLELISM.read(config_file))
     return GCSConfig(**kwargs)
Esempio n. 4
0
 def auto(
         cls,
         config_file: typing.Union[str,
                                   ConfigFile] = None) -> SecretsConfig:
     """
     Reads from environment variable or from config file
     :param config_file:
     :return:
     """
     config_file = get_config_file(config_file)
     kwargs = {}
     kwargs = set_if_exists(kwargs, "env_prefix",
                            _internal.Secrets.ENV_PREFIX.read(config_file))
     kwargs = set_if_exists(kwargs, "default_dir",
                            _internal.Secrets.DEFAULT_DIR.read(config_file))
     kwargs = set_if_exists(kwargs, "file_prefix",
                            _internal.Secrets.FILE_PREFIX.read(config_file))
     return SecretsConfig(**kwargs)
Esempio n. 5
0
 def auto(cls,
          config_file: typing.Union[str, ConfigFile] = None) -> StatsConfig:
     """
     Reads from environment variable, followed by ConfigFile provided
     :param config_file:
     :return:
     """
     config_file = get_config_file(config_file)
     kwargs = {}
     kwargs = set_if_exists(kwargs, "host",
                            _internal.StatsD.HOST.read(config_file))
     kwargs = set_if_exists(kwargs, "port",
                            _internal.StatsD.PORT.read(config_file))
     kwargs = set_if_exists(kwargs, "disabled",
                            _internal.StatsD.DISABLED.read(config_file))
     kwargs = set_if_exists(kwargs, "disabled_tags",
                            _internal.StatsD.DISABLE_TAGS.read(config_file))
     return StatsConfig(**kwargs)
Esempio n. 6
0
    def auto(cls, config_file: typing.Union[str, ConfigFile] = None) -> Config:
        """
        Automatically constructs the Config Object. The order of precedence is as follows
          1. first try to find any env vars that match the config vars specified in the FLYTE_CONFIG format.
          2. If not found in environment then values ar read from the config file
          3. If not found in the file, then the default values are used.

        :param config_file: file path to read the config from, if not specified default locations are searched
        :return: Config
        """
        config_file = get_config_file(config_file)
        kwargs = {}
        set_if_exists(kwargs, "local_sandbox_path",
                      _internal.LocalSDK.LOCAL_SANDBOX.read(cfg=config_file))
        return Config(
            platform=PlatformConfig.auto(config_file),
            secrets=SecretsConfig.auto(config_file),
            stats=StatsConfig.auto(config_file),
            data_config=DataConfig.auto(config_file),
            **kwargs,
        )
Esempio n. 7
0
    def auto(
        cls,
        config_file: typing.Optional[typing.Union[str, ConfigFile]] = None
    ) -> PlatformConfig:
        """
        Reads from Config file, and overrides from Environment variables. Refer to ConfigEntry for details
        :param config_file:
        :return:
        """
        config_file = get_config_file(config_file)
        kwargs = {}
        kwargs = set_if_exists(kwargs, "insecure",
                               _internal.Platform.INSECURE.read(config_file))
        kwargs = set_if_exists(
            kwargs, "insecure_skip_verify",
            _internal.Platform.INSECURE_SKIP_VERIFY.read(config_file))
        kwargs = set_if_exists(kwargs, "command",
                               _internal.Credentials.COMMAND.read(config_file))
        kwargs = set_if_exists(
            kwargs, "client_id",
            _internal.Credentials.CLIENT_ID.read(config_file))
        kwargs = set_if_exists(
            kwargs, "client_credentials_secret",
            _internal.Credentials.CLIENT_CREDENTIALS_SECRET.read(config_file))

        kwargs = set_if_exists(
            kwargs,
            "client_credentials_secret",
            read_file_if_exists(
                _internal.Credentials.CLIENT_CREDENTIALS_SECRET_LOCATION.read(
                    config_file)),
        )
        kwargs = set_if_exists(kwargs, "scopes",
                               _internal.Credentials.SCOPES.read(config_file))
        kwargs = set_if_exists(
            kwargs, "auth_mode",
            _internal.Credentials.AUTH_MODE.read(config_file))
        kwargs = set_if_exists(kwargs, "endpoint",
                               _internal.Platform.URL.read(config_file))
        return PlatformConfig(**kwargs)
Esempio n. 8
0
 def auto(cls,
          config_file: typing.Union[str, ConfigFile] = None) -> S3Config:
     """
     Automatically configure
     :param config_file:
     :return: Config
     """
     config_file = get_config_file(config_file)
     kwargs = {}
     kwargs = set_if_exists(kwargs, "enable_debug",
                            _internal.AWS.ENABLE_DEBUG.read(config_file))
     kwargs = set_if_exists(kwargs, "endpoint",
                            _internal.AWS.S3_ENDPOINT.read(config_file))
     kwargs = set_if_exists(kwargs, "retries",
                            _internal.AWS.RETRIES.read(config_file))
     kwargs = set_if_exists(kwargs, "backoff",
                            _internal.AWS.BACKOFF_SECONDS.read(config_file))
     kwargs = set_if_exists(
         kwargs, "access_key_id",
         _internal.AWS.S3_ACCESS_KEY_ID.read(config_file))
     kwargs = set_if_exists(
         kwargs, "secret_access_key",
         _internal.AWS.S3_SECRET_ACCESS_KEY.read(config_file))
     return S3Config(**kwargs)