Dev zone/Reports: Difference between revisions

From Nasqueron Agora
(Created page with "The Nasqueron internal reports repository is a monorepo containing SQL queries and tools to produce reports about Nasqueron internal data. == Python tools == === Configure PYTHONPATH === Python allows to develop several packages at the same time providing all the src/ folders to your PYTHONPATH variables. First, ensure you don't have any module installed through .whl running <code>pip freeze</code>. If you see something like <code>nasqueron-reports==0.1.0</code>, it co...")
 
(→‎Environment script: Avoid PYTHONPATH repetitions)
Line 16: Line 16:
#!/bin/sh
#!/bin/sh


# Not intended to contain actual credentials, but it allows to validate env config
export DB_USERNAME=someuser
export DB_USERNAME=someuser
export DB_PASSWORD=somepass
export DB_PASSWORD=somepass
export VAULT_ADDR=https://localhost:8200
#  -------------------------------------------------------------
#  Python paths
#
#  Modules are in tools/*/src
#  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
current_dir=$(pwd)
full_path=""


# shellcheck disable=SC2044
# shellcheck disable=SC2044
for dir in $(find tools -type d -name src); do
for dir in $(find tools -type d -name src); do
     if [ "$PYTHONPATH" = "" ]; then
     if [ "$full_path" = "" ]; then
         export PYTHONPATH="$dir"
         export full_path="$current_dir/$dir"
     else
     else
         export PYTHONPATH="$PYTHONPATH:$dir"
         export full_path="$full_path:$current_dir/$dir"
     fi
     fi
done
done


export VAULT_ADDR=https://localhost:8200
if [ "$PYTHONPATH" != "$full_path" ]; then
    if [ "$PYTHONPATH" = "" ]; then
        export PYTHONPATH="$full_path"
    else
        export PYTHONPATH="$PYTHONPATH:$full_path"
    fi
fi
</syntaxhighlight>
</syntaxhighlight>


If you call it .env, you can use <code>source .env</code>, but your IDE will complain it contains shell stuff. Override file type as shell script or save it under another name.
If you call it .env, you can use <code>source .env</code>, but your IDE will complain it contains shell stuff. Override file type as shell script or save it under another name.

Revision as of 13:08, 14 September 2025

The Nasqueron internal reports repository is a monorepo containing SQL queries and tools to produce reports about Nasqueron internal data.

Python tools

Configure PYTHONPATH

Python allows to develop several packages at the same time providing all the src/ folders to your PYTHONPATH variables.

First, ensure you don't have any module installed through .whl running pip freeze. If you see something like nasqueron-reports==0.1.0, it comes from package auto detection and it's fine and will use your local code. What is not fine is a long line with wheel archive.

Then, include every tools/*/src include in your path. The environment script takes care of that.

Environment script

You can use this environment configuration script for sh, bash and zsh:

#!/bin/sh

export DB_USERNAME=someuser
export DB_PASSWORD=somepass

export VAULT_ADDR=https://localhost:8200

#   -------------------------------------------------------------
#   Python paths
#
#   Modules are in tools/*/src
#   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

current_dir=$(pwd)
full_path=""

# shellcheck disable=SC2044
for dir in $(find tools -type d -name src); do
    if [ "$full_path" = "" ]; then
        export full_path="$current_dir/$dir"
    else
        export full_path="$full_path:$current_dir/$dir"
    fi
done

if [ "$PYTHONPATH" != "$full_path" ]; then
    if [ "$PYTHONPATH" = "" ]; then
        export PYTHONPATH="$full_path"
    else
        export PYTHONPATH="$PYTHONPATH:$full_path"
    fi
fi

If you call it .env, you can use source .env, but your IDE will complain it contains shell stuff. Override file type as shell script or save it under another name.