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-3453] Add python unbuffered environment variable #1156

Merged
merged 6 commits into from
Oct 30, 2024

Conversation

ben-cutler-datarobot
Copy link
Contributor

@ben-cutler-datarobot ben-cutler-datarobot commented Oct 28, 2024

This repository is public. Do not put here any private DataRobot or customer's data: code, datasets, model artifacts, .etc.

The way docker containers run python makes

print("my-statement-here")

Causes the print statements to not show up in the DataRobot logging APIs (eg /api/v2/customApplications/<id>/logs/ )
docker-library/python#604

We could make customers run:

print('my-statement-here', file=sys.stderr)

but that would be a clunky solution.

We can add the environment variable PYTHONUNBUFFERED to the containers.

Summary

Rationale

@engprod-2 engprod-2 bot changed the title [YOLO] Add python unbuffered environment variable [APP-3453] Add python unbuffered environment variable Oct 28, 2024
@engprod-2
Copy link

engprod-2 bot commented Oct 28, 2024

The Needs Review labels were added based on the following file changes.

Team @datarobot/applications (#applications) was assigned because of changes in files:

public_dropin_environments/python312/Dockerfile
public_dropin_environments/python39_streamlit/Dockerfile

Team @datarobot/buzok (#buzok) was assigned because of changes in files:

public_dropin_environments/python311_genai/Dockerfile

Team @datarobot/codegen (#scoring-code) was assigned because of changes in files:

public_dropin_environments/python311_genai/Dockerfile

Team @datarobot/custom-models (#custom-models) was assigned because of changes in files:

public_dropin_environments/python312/Dockerfile
public_dropin_environments/python39_streamlit/Dockerfile

If you think that there are some issues with ownership, please discuss with C&A domain at #core-backend-domain slack channel and create PR to update DRCODEOWNERS\CODEOWNERS file.

@engprod-2
Copy link

engprod-2 bot commented Oct 28, 2024

Label Needs Review: Scoring Code was removed because @shopin32 is part of Scoring Code domain.

@@ -2,6 +2,9 @@
# It contains a variety of common useful data-science packages and tools.
FROM datarobot/dropin-env-base-jdk:ubi8.8-py3.11-jdk11.0.22-drum1.11.5-mlops9.2.8

# This makes print statements show up in the logs API
ENV PYTHONUNBUFFERED=1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was right about to do this for all environments. Can I ask you to add this to others as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it seems like there is no reason to not set this in Dockerfile where isatty() is not reliable (https://bugs.python.org/issue41449).

However, we may get more bang for our buck if we update the envs in https://github.com/datarobot/datarobot-user-models/tree/master/docker and then update any envs that don't extend those base images.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to update the base image and also exceptions if they dont inherit from the base.

@ben-cutler-datarobot thank you for the PR, would you be up for this job?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing

Copy link
Collaborator

@klichukb klichukb Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!
I think we can introduce to the listed python-aware base dropins. @yakov-g can you please assist with publishing new versions of the base image to our dockerhub?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several base images, at least dropin-env-base and dropin-env-base-jdk are used in several of our environments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize the jdk one had python. Got it as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PLease don't merge, I'll add into one more base image.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, can merge

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold on again.
I'll update drum and image tag in the base envs

@yakov-g
Copy link
Collaborator

yakov-g commented Oct 30, 2024

Done.
I'll run piplelines to publish base images.
When I worked on those pipelines I did all the testing, but never published new ones. So I'll do this.

@ben-cutler-datarobot ben-cutler-datarobot merged commit 5378ea0 into master Oct 30, 2024
19 checks passed
@svc-engprod-git1 svc-engprod-git1 deleted the YOLO-add-python-unbuffered branch October 30, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants