Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/app is missing in PYTHONPATH in container image #31497

Open
3 tasks done
LucasRakotomalala opened this issue Dec 17, 2024 · 5 comments
Open
3 tasks done

/app is missing in PYTHONPATH in container image #31497

LucasRakotomalala opened this issue Dec 17, 2024 · 5 comments
Assignees

Comments

@LucasRakotomalala
Copy link

LucasRakotomalala commented Dec 17, 2024

Bug description

I am using Superset through the Helmchart from this repository.

When I mount something under extraConfigMountPath (with the default value /app/configs), Python files cannot be used in superset_config.py since /app folder is missing from PYTHONPATH.
I use it to provide Python files for SSO authentication, to avoid using Flask-OIDC.

In Superset 4.0.2 however /app folder was part of PYTHONPATH.

Screenshots/recordings

N/A

Superset version

4.1.1

Python version

3.10

Node version

Not applicable

Browser

Not applicable

Additional context

Here is the trace I got from Superset Init DB job:

ModuleNotFoundError: No module named `configs.authentication`

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@LucasRakotomalala LucasRakotomalala changed the title /app is missing in PYTHONPATH [docker] [chart] /app is missing in PYTHONPATH Dec 17, 2024
@LucasRakotomalala LucasRakotomalala changed the title [docker] [chart] /app is missing in PYTHONPATH /app is missing in PYTHONPATH in container image Dec 17, 2024
Copy link

dosubot bot commented Dec 17, 2024

Hey @LucasRakotomalala! 👋 I'm here to help you with any bugs, questions, or contributions you have for the Superset Helmchart. I'm looking forward to assisting you with this issue.

In Superset version 4.1.1, the PYTHONPATH environment variable in the Docker image is set to:

PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev

This configuration does not include the /app directory directly in the PYTHONPATH, which might be causing the issue you're experiencing with the ModuleNotFoundError for your custom authentication module [1].

To resolve this, you can modify the PYTHONPATH to include /app by setting an environment variable in your Helm chart configuration. You can do this by adding an env section in your Helm values file or directly in the deployment configuration to append /app to the PYTHONPATH. Here's an example of how you might adjust the PYTHONPATH:

env:
  - name: PYTHONPATH
    value: /app:/app/pythonpath:/app/docker/pythonpath_dev

This should allow your custom Python files to be recognized by Superset.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the deploy:helm label Dec 17, 2024
@LucasRakotomalala
Copy link
Author

@dosu Why /app was present in PYTHONPATH for Superset 4.0.2 without any workaround, and not in Superset 4.1.1?

Copy link

dosubot bot commented Dec 17, 2024

The default PYTHONPATH configuration in the Dockerfile for Superset version 4.0.2 included /app as part of the path, which allowed modules in that directory to be recognized without additional configuration [1][2]. However, in version 4.1.1, the PYTHONPATH was changed to exclude /app, which is why you're experiencing the ModuleNotFoundError for your custom modules. Unfortunately, I couldn't find specific documentation or changelog entries explaining the rationale behind this change.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@LucasRakotomalala
Copy link
Author

@dosu Could you please provide me some code example to add /app to PYTHONPATH by extending the current Docker image.

Copy link

dosubot bot commented Dec 17, 2024

To extend the current Docker image and add /app to the PYTHONPATH, you can modify the Dockerfile or the entrypoint script. Here's an example of how you can do it in the Dockerfile:

FROM apache/superset:4.1.1

# Add /app to PYTHONPATH
ENV PYTHONPATH="/app:${PYTHONPATH}"

Alternatively, if you're using a docker-compose.yml file, you can add the environment variable directly to the superset service:

services:
  superset:
    image: apache/superset:4.1.1
    environment:
      - PYTHONPATH=/app:${PYTHONPATH}
    # other configurations...

These changes will ensure that /app is included in the PYTHONPATH, allowing your custom Python files to be recognized by Superset.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants