fast-exabyte-27287
02/14/2024, 4:39 AMpython_sources()careful-address-89803
02/14/2024, 4:41 AMpython_sources and the resources here.careful-address-89803
02/14/2024, 4:47 AMfast-exabyte-27287
02/14/2024, 5:06 AMpython_sources(
dependencies=[":data"],
)
resources(
name="data",
sources=["*.json"],
)careful-address-89803
02/14/2024, 5:07 AMfast-exabyte-27287
02/14/2024, 5:12 AMcareful-address-89803
02/14/2024, 5:13 AMcareful-address-89803
02/14/2024, 7:19 AM--keep-sandboxes=always, or that you're getting FileNotFoundError or something like that? If they show up with --keep-sandboxes but you still get errors saying it's not there, Python package resource loading might be the cause. The files have to exist in a python package for importlib to load it. you might need to add a __init__.py in the dir and a python_sources target to grab it.broad-processor-92400
02/14/2024, 10:13 AMstring_imports = true in pants.toml? What version of pants?fast-exabyte-27287
02/15/2024, 12:05 AMstring_imports = true is not set. im using 2.18.0fast-exabyte-27287
02/15/2024, 12:09 AMcareful-address-89803
02/15/2024, 12:54 AMresources won't be able to be opened with open, for that you'd want files (but then also those files aren't included in python packages).
I think the issue might be that you're using a filepath instead of a package in the call to importlib.resources.open_text. You might need to try with something like
import data.seed.common
f = importlib.resources.open_text(data.seed.common, "capability.json")
The error message you get is a little helpful, it can indicate whether the problem is about resolving the package itself or whether the package resolution suceeded but the resource didn't come withcareful-address-89803
02/15/2024, 12:55 AM--keep-sandboxes arg will preserve the environment where Pants expanded the PEX to. You can then inspect it for whether the files showed up and it's an importlib loading thing or whether they didn't show up at all.fast-exabyte-27287
02/15/2024, 1:22 AM12:20:41.23 [WARN] Pants cannot infer owners for the following imports in the target src/data/seed/dev/seed.py:
* src.data.seed.common (line: 7)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.18/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
^CTraceback (most recent call last):
File "/private/var/folders/rq/g_3vlcwn3z99ssl__23dcwv40000gn/T/pants-sandbox-37YFRx/./.cache/pex_root/venvs/677e24f7e4da96ef93f1f1466b335cc5cb90c257/3ee58c3b3b7f54fee5790e90b78eab18840cf1a3/pex", line 274, in <module>
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/runpy.py", line 225, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/private/var/folders/rq/g_3vlcwn3z99ssl__23dcwv40000gn/T/pants-sandbox-37YFRx/src/tasks/seed.py", line 11, in <module>
from crud.profile import _update_profile, create_profile_from_dict
File "/private/var/folders/rq/g_3vlcwn3z99ssl__23dcwv40000gn/T/pants-sandbox-37YFRx/src/crud/profile.py", line 31, in <module>
from core.utils.powerpoint.template import ProfileMachinePPT
File "/private/var/folders/rq/g_3vlcwn3z99ssl__23dcwv40000gn/T/pants-sandbox-37YFRx/src/core/utils/powerpoint/template.py", line 17, in <module>
for root, dirs, files in os.walk("/"):
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/os.py", line 418, in _walk
yield from _walk(new_path, topdown, onerror, followlinks)
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/os.py", line 418, in _walk
yield from _walk(new_path, topdown, onerror, followlinks)
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/os.py", line 418, in _walk
yield from _walk(new_path, topdown, onerror, followlinks)
[Previous line repeated 6 more times]
File "/Users/harsmith/.pyenv/versions/3.9.16/lib/python3.9/os.py", line 357, in _walk
scandir_it = scandir(top)
KeyboardInterrupt
Interrupted by user.
make: *** [backend/run/seed/local] Error 1
Ive been different packages and i get the same message. When i use --keep-sandboxes the files are missing from the folderfast-exabyte-27287
02/15/2024, 1:28 AMfast-exabyte-27287
02/15/2024, 1:28 AMfast-exabyte-27287
02/15/2024, 1:30 AMpython_sources(
dependencies=[":data"],
)
files(
name="data",
sources=["*.json"],
)
In my BUILD file for common and adding init.py to common, did the trickcareful-address-89803
02/15/2024, 1:32 AMpython_sources target has the dependency link to "data" target. I was thinking that the dep chain might've not been working. I think the link you added might tie it together transitivelycareful-address-89803
02/15/2024, 1:34 AMpants dependencies for individual targets, and the --transitive for all transitive deps too