OpenGen / GenSQL.query

42 stars 5 forks source link

Generate a separate deps-lock.json and container derivation that includes SPPL #94

Closed ships closed 6 months ago

ships commented 7 months ago

This is the first time we have a successfully building docker image with query and sppl. This changeset could be refactored to use abstractions in https://github.com/InferenceQL/nix , so I am leaving this in draft state for now. It is unclear whether that repo should be upstream or downstream of package repos like this one.

To try out this image:

docker run -it probcomp/inferenceql.query-sppl:aarch64-linux bash
$ python
>>> import sppl

# it works

To mount a ./data directory to /data inside the image:

docker run -v ./data:/data -it probcomp/inferenceql.query-sppl:aarch64-linux bash

the entrypoint is still iql if you run it without a command:

docker run -it probcomp/inferenceql.query-sppl:aarch64-linux
iql>

I haven't yet got around to running the builder on an x86_64 machine yet, but you should be able to build it on this branch by running locally:

nix build .#ociImgSppl
docker load -i result
docker run -it probcomp/inferenceql.query-sppl
KingMob commented 7 months ago

Since I have an x86 mac, I checked out your branch and ran nix build .#ociImgSppl. I got the following:

Code/probcomp/inferenceql.query (dfe4c68) [!?][ v21][ v20.11.1][ impure (nix-shell-env)]❯
nix build .#ociImgSppl
warning: Git tree '/Users/matthew/Code/probcomp/inferenceql.query' is dirty
error:
       … while evaluating the attribute 'optionalValue.value'

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:856:5:

          855|
          856|     optionalValue =
             |     ^
          857|       if isDefined then { value = mergedValue; }

       … while evaluating a branch condition

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:857:7:

          856|     optionalValue =
          857|       if isDefined then { value = mergedValue; }
             |       ^
          858|       else {};

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: getting status of '/nix/store/d2xq26lzcwgz8651yrgha6m2iw84mfx7-source/nix/oci/sppl.nix': No such file or directory

Rerunning with --show-trace gives me:

nix build .#ociImgSppl --show-trace
warning: Git tree '/Users/matthew/Code/probcomp/inferenceql.query' is dirty
error:
       … while calling anonymous lambda

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/types.nix:592:29:

          591|       merge = loc: defs:
          592|         zipAttrsWith (name: defs:
             |                             ^
          593|           let merged = mergeDefinitions (loc ++ [name]) elemType defs;

       … while calling anonymous lambda

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:824:28:

          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                            ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/5yhqhsl8x9xmhsy3ql8hi05c3zbnxx2x-source/modules/transposition.nix':

       … from call site

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … while calling anonymous lambda

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/types.nix:592:29:

          591|       merge = loc: defs:
          592|         zipAttrsWith (name: defs:
             |                             ^
          593|           let merged = mergeDefinitions (loc ++ [name]) elemType defs;

       … while calling anonymous lambda

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:824:28:

          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                            ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating definitions from `/nix/store/d2xq26lzcwgz8651yrgha6m2iw84mfx7-source/flake.nix, via option perSystem':

       … from call site

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:825:137:

          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'

         at /nix/store/5gc4ncnkzcgma8fl1qabm8v9kj7w68gl-source/lib/modules.nix:896:25:

          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … from call site

         at /nix/store/d2xq26lzcwgz8651yrgha6m2iw84mfx7-source/flake.nix:59:22:

           58|
           59|         ociImgSppl = pkgs.callPackage ./nix/oci/sppl.nix {
             |                      ^
           60|           inherit pname basicToolsFn;

       … while calling 'callPackageWith'

         at /nix/store/sb3x0gk95v9h285ch8cdqv3gfjp97p1b-source/lib/customisation.nix:141:35:

          140|   */
          141|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          142|     let

       … from call site

         at /nix/store/sb3x0gk95v9h285ch8cdqv3gfjp97p1b-source/lib/customisation.nix:154:10:

          153|         # Filter out arguments that have a default value
          154|         (lib.filterAttrs (name: value: ! value)
             |          ^
          155|         # Filter out arguments that would be passed

       … while calling 'filterAttrs'

         at /nix/store/sb3x0gk95v9h285ch8cdqv3gfjp97p1b-source/lib/attrsets.nix:381:5:

          380|     # The attribute set to filter
          381|     set:
             |     ^
          382|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

         at /nix/store/sb3x0gk95v9h285ch8cdqv3gfjp97p1b-source/lib/customisation.nix:144:15:

          143|       f = if lib.isFunction fn then fn else import fn;
          144|       fargs = lib.functionArgs f;
             |               ^
          145|

       … while calling 'functionArgs'

         at /nix/store/sb3x0gk95v9h285ch8cdqv3gfjp97p1b-source/lib/trivial.nix:440:18:

          439|   */
          440|   functionArgs = f:
             |                  ^
          441|     if f ? __functor

       error: getting status of '/nix/store/d2xq26lzcwgz8651yrgha6m2iw84mfx7-source/nix/oci/sppl.nix': No such file or directory
ships commented 6 months ago

This is no longer applicable as we have determined it is possible with clever use of extra-deps to accomplish this without a separate cache.