From eac663c3a8e3659f8710ea637eebd889c65701fb Mon Sep 17 00:00:00 2001 From: AMBERMW13 Date: Wed, 24 Jul 2024 13:09:24 -0600 Subject: [PATCH] DAT-17171 --- .../checks-python-package.htm | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Content/commands/quality-checks/custom-policy-checks/checks-python-package.htm b/Content/commands/quality-checks/custom-policy-checks/checks-python-package.htm index 3f709b648..141ae2495 100644 --- a/Content/commands/quality-checks/custom-policy-checks/checks-python-package.htm +++ b/Content/commands/quality-checks/custom-policy-checks/checks-python-package.htm @@ -38,21 +38,14 @@

Step-by-step instructions

  • Once the environment is active, install packages using pip install <some package>.
  • Provide a path to the Python executable that is based on your virtual environment so can recognize the environment.
    liquibase --script-python-executable-path ./your/path/to/venv/bin/python checks run --check-name MySweetPythonCheck --checks-scripts-enabled --checks-scope database
  • -
      -
    1. Create a virtual environment in your directory that contains the custom policy check script by running the following in the CLI:

      python -m venv <path to your venv>

    2. -
    3. Install the package by running pip install liquibase-checks-python in the CLI.
    4. -
    5. Navigate to the location where you import liquibase_utilities and replace import liquibase_utilities with from liquibase_checks_python import liquibase_utilities in your Python script.
      Now the Python package that includes the helper scripts is activated.
    6. -
    7. Next you will call on a specific helper script.
      In this example we will run logger = liquibase_utilities.get_logger
    8. -
    9. When the check runs it will retrieve any content it finds based on the criteria you asked for and display it in the CLI.
    10. -

    Install the Python package

    -

    provides a Python package called liquibase-checks-python to assist with in-IDE documentation and auto complete with your helper scripts. Install our Python package by following these instructions.

    +

    Now that you've configured and ran a standard custom policy check you're ready to cover using the Python package. provides a Python package called liquibase-checks-python to assist with in-IDE documentation and auto complete with your helper scripts. Install our Python package by following these instructions.

    If you want the custom policy check helper scripts with in-IDE documentation and auto-complete, you must complete the Install the Python package steps first. If you want the custom policy check helper scripts without those features, skip that section and follow the Access helper scripts steps.

    -

    Step-by-step

    +

    Install the Python package step-by-step

    +

    This option allows you to enhance your checks further with usage of specific items within the Python package.

      -
    1. Create a virtual environment in your directory that contains the custom policy check script by running the following in the CLI:

      python -m venv <path to your venv>

    2. -
    3. Install the Python package by running pip install liquibase-checks-python in the CLI.
    4. -
    5. In your custom policy check file, replace import liquibase_utilities with from liquibase_checks_python import liquibase_utilities in your Python script.
      1. import sys # useful for indicating a check has been triggered +
      2. In your virtual environment, install the Python package by running pip install liquibase-checks-python in the CLI.
      3. +
      4. In your custom policy check file, replace import liquibase_utilities with from liquibase_checks_python import liquibase_utilities in your Python script.
        import sys # useful for indicating a check has been triggered from liquibase_checks_python import liquibase_utilities as lb # this is where we are importing our liquibase_utilities helper script provided by the liquibase-checks-python package obj = lb.get_database_object() # this gets the database object the liquibase policy check is examining @@ -61,7 +54,15 @@

        Step-by-step

        if lb.is_table(obj): # function provided from liquibase utilities status.fired = True # indicates the custom check has been triggered status.message = No tables allowed! # set the message of the custom check, which liquibase will return - sys.exit(1) # exit from the check
      You have successfully activated the Checks Python package. Next you will go over usage of our helper scripts.
    6. + sys.exit(1) # exit from the check

      You have successfully activated the Checks Python package. Next you will go over usage of our helper scripts.

      +
    +

    Install the Python package and import tools step-by-step

    +

    This option allows you to enhance your checks further with usage of specific items within the Python package.

    +
      +
    1. In your virtual environment, install the package by running pip install liquibase-checks-python in the CLI.
    2. +
    3. Navigate to the location where you import liquibase_utilities and replace import liquibase_utilities with from liquibase_checks_python import liquibase_utilities in your Python script.
      Now the Python package that includes the helper scripts is activated.
    4. +
    5. Next you will call on a specific helper script.
      In this example we will run logger = liquibase_utilities.get_logger
    6. +
    7. When the check runs it will retrieve any content it finds based on the criteria you asked for and display it in the CLI.

    Access helper scripts

    Step-by-step