#!/usr/bin/env python# -*- coding: utf-8; -*-# Copyright (c) 2022, 2023 Oracle and/or its affiliates.# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/importbase64importjsonimportosfromtypingimportDictfromtypingimportTupleimportinflectionimportyamlimportglobfromads.common.authimportcreate_signerfromads.opctlimportloggerfromads.opctl.config.baseimportConfigProcessorfromads.opctl.config.utilsimportNotSupportedError,convert_notebookfromads.opctl.constantsimport(ML_JOB_GPU_IMAGE,ML_JOB_IMAGE,)fromads.opctl.utilsimport(list_ads_operators,parse_conda_uri,get_region_key,get_namespace,)YAML_STRUCTURES={"v0":{"infrastructure":["infrastructure"],"image":["execution","image"],},"v1":{"infrastructure":["spec","Infrastructure","spec"],},}
[docs]classConfigVersioner(ConfigProcessor):""" ads opctl supports multiple yaml file types, kinds and versions. Each has its own slightly different yaml structure. This goal of this class is to provide a translation from the generic term for a variable to it's specific path in it's yaml. """def__init__(self,config:Dict=None)->None:super().__init__(config)self.ads_operators=list_ads_operators()
[docs]defprocess(self):# this function should be run after merging configs# conda pack scenarios --# - user runs their own scripts and commands -> source_folder + entrypoint + (command)# - user runs ADS operator -> name/YAML# docker image scenarios --# - user runs their own docker image -> image (to run) + (entrypoint) + (command)# - user runs ADS operator -> name/YAML# TODO: build this outreturnself