#!/usr/bin/env python# -*- coding: utf-8 -*--# Copyright (c) 2020, 2023 Oracle and/or its affiliates.# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/from__future__importprint_function,division,absolute_importimportosimportsysimportloggingimportjsonfromtypingimportCallable,Dict,Optional,Union# https://packaging.python.org/en/latest/guides/single-sourcing-package-version/#single-sourcing-the-package-versionifsys.version_info>=(3,8):fromimportlibimportmetadataelse:importimportlib_metadataasmetadata__version__=metadata.version("oracle_ads")importociimportmatplotlib.font_manager# causes matplotlib to regenerate its fontsimportocifsfromads.common.decorator.deprecateimportdeprecatedfromads.common.ipythonimportconfigure_plotting,_log_tracebackfromads.feature_engineering.accessor.series_accessorimportADSSeriesAccessorfromads.feature_engineering.accessor.dataframe_accessorimportADSDataFrameAccessorfromads.commonimportauthfromads.common.authimportset_authfromads.common.configimportConfigos.environ["GIT_PYTHON_REFRESH"]="quiet"debug_mode=os.environ.get("DEBUG_MODE",False)documentation_mode=os.environ.get("DOCUMENTATION_MODE","False")=="True"test_mode=os.environ.get("TEST_MODE",False)resource_principal_mode=bool(os.environ.get("RESOURCE_PRINCIPAL_MODE",False))# deprecated with is_resource_principal_mode() from ads.common.utilsorig_ipython_traceback=None
logger=getLogger(__name__)logger.addHandler(logging.NullHandler())# All warnings are logged by defaultlogging.captureWarnings(True)
[docs]defset_debug_mode(mode=True):""" Enable/disable printing stack traces on notebook. Parameters ---------- mode: bool (default True) Enable/disable print stack traces on notebook """globaldebug_modedebug_mode=modeimportIPythonifdebug_mode:fromads.common.ipythonimportorig_ipython_tracebackIPython.core.interactiveshell.InteractiveShell.showtraceback=(orig_ipython_traceback)else:IPython.core.interactiveshell.InteractiveShell.showtraceback=_log_traceback
[docs]@deprecated("2.3.1")defset_documentation_mode(mode=False):""" This method is deprecated and will be removed in future releases. Enable/disable printing user tips on notebook. Parameters ---------- mode: bool (default False) Enable/disable print user tips on notebook """globaldocumentation_modedocumentation_mode=mode
[docs]@deprecated("2.3.1")defset_expert_mode():""" This method is deprecated and will be removed in future releases. Enables the debug and documentation mode for expert users all in one method. """set_debug_mode(True)set_documentation_mode(False)
## ***FOR TESTING PURPOSE ONLY***#def_set_test_mode(mode=False):""" Enable/disable intercept the automl call and rewrite it to always use the two algorithms (LogisticRegression for classification and LinearRegression for regression). Enable only during tests to reduce nb convert notebook tests run time. Parameters ---------- mode: bool (default False) Enable/disable the ability to intercept automl call """globaltest_modetest_mode=mode
[docs]defhello():importociimportocifsprint(f""" O o-o o-o / \\ | \\ |o---o| O o-o| || / |o oo-o o--oads v{__version__}oci v{oci.__version__}ocifs v{ocifs.__version__}""")