Getting started with my jupyter-book plugin. initi...
# plugins
l
Getting started with my jupyter-book plugin. initially looks like I need to run
jupyter-book build .
on the folder containing all the doc files. I'm working creating the
digest
that would hold those, but it seems like most of the digest related stuff is for operating on individual files. How would I set up a
digest
that matches the directory structure of a
docs
directory and then run my
Process
on that directory?
b
Make a request from PathGlobs (doesn't have to be globs, can be static paths) to a digest?
l
yeah so I've got
Copy code
digest = await Get(Digest, PathGlobs(["docs/**"]))
result = await Get(ProcessResult, Process(argv=["jupyter-book", "build", "."], description="", input_digest=digest))
getting a
"No such file or directory"
error though.
I'm just not fully understanding the whole digest thing yet I suppose.
b
You can also set breakpoints and debug by using PANTS_DEBUG=1 on your command
(sorry on mobile, the formatting was weird)
So the path globs are relative to your build root, is that the case here?
l
That's right.
Essentially, trying to run that command on the docs directory as a whole.
b
Additionally running your command with --keep-sandboxes=always will leak and log sandboxes. Those are great for poking around in
l
I'm thinking I may actually want to use
InteractiveProcess
though, since I'm actually looking to get the newly created files out
b
Process is probably correct, there's output fields to get the files out.
Should your command be using "docs" instead of "."?
l
Could be... but if I pass the digest as an
input_digest
then wouldn't the files be at the
pwd
level?
need to get the breakpoints working so I can inspect I think
b
In this case poking around the sandbox is easier and will be very obvious what is on disk when your command is running
I suspect the docs prefix is a part of the digest
l
cool. Yup you're right.
weirdly the command still says file isn't found, even though if I run it on the sandbox directory it works (well it throws a different exception..)
ahh I think the "no file" error is because pants doesn't know what
jupyter-book
is. So I think I need to make sure that gets installed in the sandbox?
b
Yup! That too! Everything the command needs to run must be handed to it. That's what makes it reproducible and hermetic (and therefore can be cached remotely or run remotely)
l
steep learning curve, but I'll get there. I got the pex installed for jupyter-book and ran the command successfully. Now just need to get the output digest back into my files.
b
Yeah, there's certainly more that can be improved. The constraints of the system make that a challenge. I usually do a whole lot of cargo culting
l
Cargo culting?
b
https://en.m.wikipedia.org/wiki/Cargo_cult In a technological context, basically means doing stuff without understanding it, because it yields the results you expect.
😆 1
l
This is generally starting to make sense. I will likely have an mvp in a day or two that will build the jupyter book then push it to a separate branch for publishing. Then I'll move it to my
pants
fork to work on testing it and getting some feedback on it.
also neat, Github Copilot helped me build a couple of the rules.
🙃 1
b
Oh I'd be very afraid of copilot writing rules lol. I'm very curious to see that 😆
Copilot would be even more of an example of cargo culting lol
l
So my two takeaways from it are that (1) the rules are very specific to pants, so it looked like it was pulling directly from the pants docs (2) the one that it got mostly right was directly below one that I had already written, so it took the context and updated it based on some initial code that I wrote.
hah! good point, pretty much any AI generated code would be cargo culting I suppose
w
I've used copilot to try to write some rules as well - it does take up some boilerplate, but it pulls straight from existing code if it thinks it can. So, lots of mistakes, and maybe some stale paradigms
l
Yeah. for this type of stuff I mostly use it for filling out the boilerplate that i can edit
w
And one day, hopefully Pants will fill some of that in via some sort of
./pants plugin init ...
🙂
l
well for now I'll be glad to wrap my own head around it
b
My quest is to make it so we wouldn't need `./pants plugin init`😤
👀 1
l
Ok so one more question (hopefully) @bitter-ability-32190 (or anyone else). How do I put some file from a digest back into my repo?
b
Gotta use a goal rule, and request the workspace as a rule param. It has the ability to write to the workspace
l
oh ok I think i found it:
workspace.write_digest()
b
🏆