pkl-python icon indicating copy to clipboard operation
pkl-python copied to clipboard

Support disabling the pkl cache for sandboxed/hermetic builds

Open mexlez12345 opened this issue 1 year ago • 4 comments

Looks like by default the codegen tries to use the "global" pkl cache at ~/.pkl.

This breaks builds that use strict sandboxing (ex. bazel) that disallow write access outside of the build directory.

To address this, would it be possible to support ex. --no-cache args similar to the "core" pkl CLI tools?

https://pkl-lang.org/main/current/pkl-cli/index.html#common-options

–– Pkl Error ––
I/O error loading module `package://github.com/jw-y/pkl-python/releases/download/v0.1.16/[email protected]#/Generator.pkl`.
FileSystemException: /home/user/.pkl: Read-only file system

1 | amends "package://github.com/jw-y/pkl-python/releases/download/v0.1.16/[email protected]#/Generator.pkl"
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
at tmpn_frdii6 (file:///tmp/tmpn_frdii6.pkl)

  warnings.warn(str(e))

mexlez12345 avatar Oct 29 '24 21:10 mexlez12345

Is there a use case that i can reproduce?

jw-y avatar Nov 08 '24 02:11 jw-y

Not sure if it will work, but try putting the Generator.pkl file into the build directory and pass the file path to --generator-settings flag.

The core pkl binary by default uses cache for remote files and you probably would want that too. If it is local, it won't use the cache.

jw-y avatar Nov 08 '24 02:11 jw-y

Probably hard to reproduce :P this is a non-trivial private codebase.

We're running https://bazel.build/ which sandboxes all build steps (ex. no access to system-wide filesystem, no network access) except for explicitly declared dependencies, so when pkl-python tries to "externally" download the pkl binary and supporting files, it gets blocked (as per error message above).

In our case bazel handles all the caching etc. for intermediates.

mexlez12345 avatar Nov 12 '24 18:11 mexlez12345

Have you tried inserting Generator.pkl into the project before build? If you don't have that file there is no way of generating python code anyways.

jw-y avatar Nov 17 '24 07:11 jw-y