Kaggle / kagglehub

Python library to access Kaggle resources
Apache License 2.0
33 stars 6 forks source link

New logging forces user to have a home folder #137

Open DavideWalder opened 1 month ago

DavideWalder commented 1 month ago

This was not the case with 0.2.5

To reproduce:

Dockerfile:

FROM python:3.12.3-slim

ARG UID=10001
RUN adduser \
    --disabled-password \
    --gecos "" \
    --shell "/sbin/nologin" \
    --no-create-home \
    --uid "${UID}" \
    appuser

RUN pip install kagglehub==0.2.6
USER $UID

ENTRYPOINT [ "python", "-c", "import kagglehub" ]
docker build -t kagglehub . && docker run --rm kagglehub
neshdev commented 1 month ago

We added additional logging capabilities to help troubleshoot user issues. This is the line that is most likely causing the issue.

Can you explain the usecase on why there isn't a user profile?

neshdev commented 1 month ago

Other parts of the kagglehub expect the user directory to exists such as downloads. We store the files in ~/.cache. This folder will be created regardless. See code here. The location is also configurable.

neshdev commented 1 month ago

@DavideWalder - Would allowing a env variable for the log path be a sufficient solution?

DavideWalder commented 1 month ago

Here is my use case: I have a containerized application using tensorflow and keras-nlp, the latter has a dependency on kagglehub (I am not using it directly). The application is a stateless container deployed on k8s, therefore running as non-root and without a home folder (since it is stateless).

There are a few design points that should be considered:

The only simple solution I see is storing logs in a folder relative to the project's root. Environment variables make the interface to the library more complex and implicit.

I already have workarounds for this problems, so not pressing for me. I just wanted to make the project aware that this is happening

DavideWalder commented 1 month ago

Another point: This is happening on import, having side-effects on imports is in general something I would avoid. Solutions could be: