rough-engineer-58925
11/15/2024, 10:28 PMpex
binary DOES NOT include langgraph.json
.rough-engineer-58925
11/15/2024, 10:28 PMdef langgraph_app(name, **kwargs):
deps = kwargs.pop("dependencies", [])
graphs = kwargs.pop("graphs")
assert graphs is not None, "graphs is a required parameter"
langgraph_json_config = f"""
{{
"graphs": {graphs},
"python_version": "3.12",
"dependencies": ["."]
}}
"""
# Create langgraph.json file.
shell_command(
name="echo_langgraph_json",
command=f"echo {langgraph_json_config} > langgraph.json",
tools=["echo"],
output_files=["langgraph.json"],
)
# Bundle it as a resource for pex_binary.
resources(
name="langgraph_json",
sources=["langgraph.json"],
dependencies=[":echo_langgraph_json"],
)
pex_binary(
name=name,
entry_point="registry.py",
dependencies=[":langgraph_json"] + deps,
**kwargs,
)
happy-kitchen-89482
11/16/2024, 5:43 PMhappy-kitchen-89482
11/16/2024, 5:43 PMresources
target points to a real file, I meanrough-engineer-58925
11/17/2024, 9:09 AMrough-engineer-58925
11/17/2024, 3:12 PMexperimentas_wrapped_as_resource
.
To be honest, that's rather surprising, and not intuitive.
Do you know who I can talk to, maybe I can see if I can help make it part of resources
directly.gorgeous-winter-99296
11/17/2024, 4:15 PMexperimental_wrap_as_resources
instead of resources
? Or did you need both?rough-engineer-58925
11/17/2024, 4:19 PMexperimental_wrap_as_resources
. I think a better API should not use it, but rather directly resources
.gorgeous-winter-99296
11/17/2024, 4:23 PMresources
did not match any files.gorgeous-winter-99296
11/17/2024, 4:29 PM17:28:45.40 [WARN] Unmatched glob from //:langgraph_json's `sources` field: "langgraph.json"
Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.18/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
gorgeous-winter-99296
11/17/2024, 4:39 PM17:36:02.30 [WARN] The target //:foobar (`pex_binary`) transitively depends on the below `files` targets, but Pants will not include them in the built package. Filesystem APIs like `open()` may be not able to load files within the binary itself; instead, they read from the current working directory.
I'm not sure why we detect but don't include file targets in pex's... it does seem actively unhelpful. @rough-engineer-58925 can you file an issue on GitHub?rough-engineer-58925
11/17/2024, 4:58 PMrough-engineer-58925
11/17/2024, 5:02 PMI'm not sure why we detect but don't include file targets in pex'sI think the answer is written here: https://www.pantsbuild.org/stable/docs/using-pants/assets-and-archives
rough-engineer-58925
11/17/2024, 5:03 PMexperimental_wrap_as_resources
.
Is there someone who I can talk to so that I can help solve this issue?gorgeous-winter-99296
11/17/2024, 7:25 PMshell_command
outputs a file
source. The experimental_wrap_as_*
helpers convert these sources to other types. These types are hard-coded inside Pants (i.e., a specific target has a specific source type), and different rules in Pants look for these specific types of files to do their work. So changing the types of sources at runtime has to happen at the target level (experimental...
), and changing the hardcoded source type of an existing target type might introduce issues for those expecting it to be the other type.gorgeous-winter-99296
11/17/2024, 7:30 PMrough-engineer-58925
11/17/2024, 7:37 PMresources
don't work out of the box.