https://pantsbuild.org/ logo
#general
Title
# general
b

brash-student-40401

10/17/2022, 8:18 PM
Has anyone tried to integrate Voila into a Pants-based project? We're using it to serve a notebook-based app. I think the problems I'm having are pretty basic, but I would appreciate a second set of eyes if anyone has any ideas! Details in 🧵
My app has a
BUILD
that looks like:
Copy code
python_sources()

python_requirement(
    name="app_analytics",
    requirements=["analytics-python~=1.4.0"],
)

python_test_utils(
    name="test_utils",
)

pex_binary(
    name="app_bin",
    entry_point="__init__.py",
    dependencies=["src/services/app/app:app_analytics"]
)

pex_binary(
    name="app_voila_bin",
    entry_point="_voila.py",
    dependencies=["src/services/app/app:app_bin"]
)
and
_voila.py
is simply
Copy code
from <http://voila.app|voila.app> import Voila
import sys

config = {}

if __name__ == "__main__":
    Voila.launch_instance(argv=sys.argv)
I try to run the
app_voila_bin
goal as so
./pants run src/services/app/app:app_voila_bin -- --option1 --option2 ... src/services/app/notebooks/app.ipynb --optionN
, which is how I would sort the options when I run Voila through Poetry. But this throws
_voila.py: error: unrecognized arguments: src/services/app/notebooks/app.ipynb
. If I try to put the Notebook path first, I instead get
ValueError: provided more than 1 argument: ['/home/vscode/.pex/unzipped_pexes/d5f6d5a9fbc653c7cb5a6dd3e16771e175d24b82/app/_voila.py', 'src/services/app/notebooks/app.ipynb']
So it looks like one way or the other, Voila is not getting the arguments properly. Any advice?
h

happy-kitchen-89482

10/17/2022, 9:32 PM
I see you have a
pex_binary
depending on another
pex_binary
, and I’m not sure that will work (or what is expected to happen)?
b

brash-student-40401

10/18/2022, 2:10 PM
That part actually seems to be working okay - basically since the Voila target is just reading a notebook, it won't grab the other stuff I need when I try to run it. But if I depend on the other guy, everything seems fine as far as dependencies go. I got around my original problem, but it seems like now I'm running into an issue with the files it's depending on, I'm going to post a different question on that.
No I was wrong - simplifying it to a
python_source
(no reason to binary it) seems to be doing maybe what I expect sort of!
5 Views