2 Install OML4Py Client for Linux for Use With Autonomous Database on Serverless Exadata Infrastructure

You can install and use the OML4Py client for Linux to work with OML4Py in an Oracle Autonomous Database on Serverless Exadata infrastructure.

OML4Py on premises runs on 64-bit platforms only. For supported platforms see OML4Py On Premises System Requirements.

The following instructions tell you how to download install Python, configure your environment, install manage your client credentials, install Oracle Instant Client, and install the OML4Py client:

  1. Download the Python 3.9.5 source and untar it:

    wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tar.xz
    tar xvf Python-3.9.5.tar.xz
  2. OML4Py requires the presence of the perl-Env, libffi-devel, openssl, openssl-devel, tk-devel, xz-devel, zlib-devel, bzip2-devel, readline-devel, libuuid-devel and ncurses-devel libraries. Confirm that they exist and install any that are missing, as follows.

    rpm -qa perl-Env
    rpm -qa libffi-devel
    rpm -qa openssl 
    rpm -qa openssl-devel
    rpm -qa tk-devel
    rpm -qa xz-devel
    rpm -qa zlib-devel
    rpm -qa bzip2-devel
    rpm -qa readline-devel
    rpm -qa libuuid-devel
    rpm -qa ncurses-devel

    If nothing is returned, install via yum:

    sudo yum install perl-Env libffi-devel openssl openssl-devel tk-devel xz-devel zlib-devel bzip2-devel readline-devel libuuid-devel ncurses-devel

    Note:

    RPMs must be installed under sudo, or root.
  3. To build Python, enter the following commands, where PREFIX is the directory in which you installed Python-3.9.5. Use make altinstall to avoid overriding the system default's Python installation.

    export PREFIX=`pwd`/Python-3.9.5
    cd $PREFIX
    ./configure --prefix=$PREFIX --enable-shared
    
    make clean; make
    make altinstall
  4. Set environment variable PYTHONHOME and add it to your PATH, and set environment variable LD_LIBRARY_PATH:

    export PYTHONHOME=$PREFIX
    export PATH=$PYTHONHOME/bin:$PATH
    export LD_LIBRARY_PATH=$PYTHONHOME/lib:$LD_LIBRARY_PATH

    Create a symbolic link in your $PYTHONHOME/bin directory. You need to link it to your python3.9 executable, which you can do with the following commands:

    cd $PYTHONHOME/bin 
    ln -s python3.9 python3

    You can now start Python with the python3 script:

    $ python3

    pip will return warnings during package installation if the latest version is not installed. You can upgrade the version of pip to avoid these warnings:

    python3 -m pip install --upgrade pip
  5. Install the Oracle Instant Client for Autonomous Database, as follows:

    Download the Oracle Instant Client for your system. Go to the Oracle Instant Client Downloads page and select Instant Client for Linux x86-64. For more instruction see Install Oracle Instant Client for Linux for On-Premises Databases.

    For instruction on installing the Oracle instant client for on-premises see Install OML4Py Client for On-Premises Databases.

    If you have root access to install an RPM on the client system. Alternatively, you can also download the zip file installer, unzip the file, and add the location of the unzipped file to LD_LIBRARY_PATH as done in next section.

    wget https://download.oracle.com/otn_software/linux/instantclient/1914000/oracle-instantclient19.14-basic-19.14.0.0.0-1.x86_64.rpm
    
    rpm -ivh oracle-instantclient19.14-basic-19.14.0.0.0-1.x86_64.rpm
    
    export LD_LIBRARY_PATH=/usr/lib/oracle/19.14/client64/lib:$LD_LIBRARY_PATH

    If you do not have root access to install an RPM on the client system.

    wget https://download.oracle.com/otn_software/linux/instantclient/1914000/instantclient-basic-linux.x64-19.14.0.0.0dbru.zip
    
    unzip instantclient-basic-linux.x64-19.14.0.0.0dbru.zip
    
    export LD_LIBRARY_PATH=/path/to/instantclient_19_4:$LD_LIBRARY_PATH
  6. Download the client credentials (wallet) from your Autonomous database. Create a directory for the Wallet contents. Unzip the wallet zip file to the newly created directory:

    Note:

    An mTLS connection using the client Wallet is required. TLS connections are not currently supported.
    mkdir -p mywalletdir
    unzip Wallet.name.zip -d mywalletdir
    $ cd mywalletdir/
    $ ls
    README       ewallet.p12   ojdbc.properties  tnsnames.ora
    cwallet.sso  keystore.jks  sqlnet.ora        truststore.jks
    
  7. Update sqlnet.ora with the wallet location. If you're working behind a proxy firewall, set the SQLNET.USE_HTTPS_PROXY environment variable to on:

    
    WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="mywalletdir")))
    SSL_SERVER_DN_MATCH=yes
    SQLNET.USE_HTTPS_PROXY=on
  8. Add proxy address information to all service levels in tnsnames.ora, and add the connection pools for all service levels. If you are behind a firewall, enter the proxy address and port number to all service levels in tnsnames.ora. You will also need to add three new entries for the AutoML connection pools as shown below.

    Note:

    If the proxy server contains a firewall to terminate connections within a set time period, the database connection will also be terminated.

    For example, myadb_medium_pool is another alias for the connection string with SERVER=POOLED added to the corresponding one for myadb_medium.

    myadb_low = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

    myadb_medium = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

    myadb_high = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

    myadb_low_pool = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com)(SERVER=POOLED))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

    myadb_medium_pool = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com)(SERVER=POOLED))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

    myadb_high_pool = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com)(SERVER=POOLED))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))

  9. Set TNS_ADMIN environment variable to the wallet directory:

    export TNS_ADMIN=mywalletdir
  10. Install OML4Py library dependencies. The versions listed here are the versions Oracle has tested and supports:

    • pip3.9 install pandas==1.3.4
    • pip3.9 install scipy==1.7.3
    • pip3.9 install matplotlib==3.3.3
    • pip3.9 install cx_Oracle==8.1.0
    • pip3.9 install threadpoolctl==2.1.0
    • pip3.9 install joblib==0.14.0
    • pip3.9 install scikit-learn==1.0.1 --no-deps
    • pip3.9 uninstall numpy
    • pip3.9 install numpy==1.21.5
    • Install OML4Py client:

      Download OML4Py client installation zip file, go to the Oracle Machine Learning for Python Downloads page on the Oracle Technology Network. For more instruction see Install OML4Py Client for Linux for On-Premises Databases

      unzip oml4py-client-linux-x86_64-1.0.zip
      
      $ perl -Iclient client/client.pl
      
      Oracle Machine Learning for Python 1.0 Client.
      
      Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved.
      Checking platform .................. Pass
      Checking Python .................... Pass
      Checking dependencies .............. Pass
      Checking OML4P version ............. Pass
      Current configuration
        Python Version ................... 3.9.5
        PYTHONHOME ....................... /opt/Python-3.9.5
        Existing OML4P module version .... None
      
        Operation ........................ Install/Upgrade
      
      Proceed? [yes]
      Processing ./client/oml-1.0-cp39-cp39-linux_x86_64.whl
      Installing collected packages: oml
      Successfully installed oml-1.0
      
      Done
    • Start Python and load the oml library:

      $ python3
      >>> import oml
      
    • Create a database connection. The OML client connects using the wallet. Set the dsn and automl arguments to the tnsnames alias in the wallet:

      oml.connect(user="oml_user", password="oml_user_password", dsn="myadb_medium", automl="myadb_medium_pool")

      To provide empty strings for the user and password parameters to connect without exposing your Oracle Machine Learning user credentials in clear text:

      oml.connect(user="", password="", dsn="myadb_medium", automl="myadb_medium_pool")