def test_file_loader_good(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), 'configs/good.config')) assert common.CONFIGURATION_SINGLETON.get_string('sdk', 'workflow_packages') == \ 'this.module,that.module' assert common.CONFIGURATION_SINGLETON.get_string( 'auth', 'assumable_iam_role') == 'some_role'
def test_file_loader_good(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config")) assert common.CONFIGURATION_SINGLETON.get_string( "sdk", "workflow_packages") == "this.module,that.module" assert common.CONFIGURATION_SINGLETON.get_string( "auth", "assumable_iam_role") == "some_role"
def test_resource_hints(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config")) assert resources.DEFAULT_CPU_REQUEST.get() == "500m" assert resources.DEFAULT_CPU_LIMIT.get() == "501m" assert resources.DEFAULT_MEMORY_REQUEST.get() == "500Gi" assert resources.DEFAULT_MEMORY_LIMIT.get() == "501Gi" assert resources.DEFAULT_GPU_REQUEST.get() == "1" assert resources.DEFAULT_GPU_LIMIT.get() == "2" assert resources.DEFAULT_STORAGE_REQUEST.get() == "500Gi" assert resources.DEFAULT_STORAGE_LIMIT.get() == "501Gi"
def test_serialization_images(): @task(container_image="{{.image.xyz.fqn}}:{{.image.default.version}}") def t1(a: int) -> int: return a @task(container_image="{{.image.default.fqn}}:{{.image.default.version}}") def t2(): pass @task def t3(): pass @task(container_image="docker.io/org/myimage:latest") def t4(): pass @task(container_image="docker.io/org/myimage:{{.image.default.version}}") def t5(a: int) -> int: return a os.environ["FLYTE_INTERNAL_IMAGE"] = "docker.io/default:version" set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/images.config")) rs = context_manager.SerializationSettings( project="project", domain="domain", version="version", env=None, image_config=get_image_config(), ) t1_ser = get_serializable(rs, t1) assert t1_ser.container.image == "docker.io/xyz:version" t1_ser.to_flyte_idl() t2_ser = get_serializable(rs, t2) assert t2_ser.container.image == "docker.io/default:version" t3_ser = get_serializable(rs, t3) assert t3_ser.container.image == "docker.io/default:version" t4_ser = get_serializable(rs, t4) assert t4_ser.container.image == "docker.io/org/myimage:latest" t5_ser = get_serializable(rs, t5) assert t5_ser.container.image == "docker.io/org/myimage:version"
def update_configuration_file(config_file_path): """ Changes the configuration singleton object to read from another file if specified, which should be at the base of the repository. :param Text config_file_path: """ configuration_file = Path(config_file_path or CONFIGURATION_PATH.get()) if configuration_file.is_file(): click.secho('Using configuration file at {}'.format(configuration_file.absolute().as_posix()), fg='green') set_flyte_config_file(configuration_file.as_posix()) else: click.secho("Configuration file '{}' could not be loaded. Using values from environment.".format(CONFIGURATION_PATH.get()), color='yellow') set_flyte_config_file(None) click.secho('Flyte Admin URL {}'.format(_URL.get()), fg='green')
def test_env_var_precedence_string(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), 'configs/good.config')) assert common.FlyteIntegerConfigurationEntry('madeup', 'int_value').get() == 3 assert common.FlyteStringConfigurationEntry('madeup', 'string_value').get() == 'abc' old_environ = dict(os.environ) try: os.environ['FLYTE_MADEUP_INT_VALUE'] = '10' os.environ["FLYTE_MADEUP_STRING_VALUE"] = 'overridden' assert common.FlyteIntegerConfigurationEntry('madeup', 'int_value').get() == 10 assert common.FlyteStringConfigurationEntry( 'madeup', 'string_value').get() == 'overridden' finally: os.environ.clear() os.environ.update(old_environ)
def test_env_var_precedence_string(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config")) assert common.FlyteIntegerConfigurationEntry("madeup", "int_value").get() == 3 assert common.FlyteStringConfigurationEntry("madeup", "string_value").get() == "abc" old_environ = dict(os.environ) try: os.environ["FLYTE_MADEUP_INT_VALUE"] = "10" os.environ["FLYTE_MADEUP_STRING_VALUE"] = "overridden" assert common.FlyteIntegerConfigurationEntry("madeup", "int_value").get() == 10 assert common.FlyteStringConfigurationEntry( "madeup", "string_value").get() == "overridden" finally: os.environ.clear() os.environ.update(old_environ)
def test_load_images(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/images.config")) imgs = images.get_specified_images() assert imgs == {"abc": "docker.io/abc", "xyz": "docker.io/xyz:latest"}
def test_no_images(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), "configs/good.config")) imgs = images.get_specified_images() assert imgs == {}
def config_load(): set_flyte_config_file("notebook.config") print("Connected to {}".format(platform.URL.get()))
def test_file_loader_bad(): set_flyte_config_file( os.path.join(os.path.dirname(os.path.realpath(__file__)), 'configs/bad.config')) with pytest.raises(Exception): common.CONFIGURATION_SINGLETON.get_string('a', 'b')