proud-byte-81916
09/11/2023, 5:01 PMpants test kittl/libs/base/tests/
it works, because the library "base" doesn't depend on any other
If I run: pants test kittl/libs/fancy/tests/
it gives me the error: ModuleNotFoundError: No module named 'kittl.libs.base'
because it doesn't have access to kitt.libs.base
but only to kittl.libs.fancy
How can I have fancy
to import base
, while keeping dependencies separated? Thanks so much! Really appreciate your help! 🙂curved-television-6568
09/11/2023, 5:10 PMcurved-television-6568
09/11/2023, 5:11 PMfiles
target in kittl/libs
seems to include all sources, and pants usually complains about files having multiple owners, so not sure if that will cause issues as well.proud-byte-81916
09/11/2023, 5:41 PMproud-byte-81916
09/11/2023, 5:41 PMbase
from fancy
- any suggestions there?curved-television-6568
09/11/2023, 5:44 PMrequirements.txt
files contributing to a shared resolve, if you really want to. not sure what happens if you put duplicate entries in them though.. so might be a hassle to track common deps 😬curved-television-6568
09/11/2023, 5:50 PM❯ pants test ::
13:46:24.66 [INFO] waiting for pantsd to start...
13:46:25.09 [INFO] pantsd started
13:46:25.49 [INFO] Initializing scheduler...
13:46:29.00 [INFO] Scheduler initialized.
13:46:29.10 [WARN] Pants cannot infer owners for the following imports in the target kittl/libs/fancy/tests/test_fancy.py:
* kittl.libs.base.adder2.add2 (line: 5)
These imports are not in the resolve used by the target (`fancy`), but they were present in other resolves:
* kittl.libs.base.adder2.add2: 'base' from kittl/libs/base/adder2.py
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.17/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
13:46:29.11 [WARN] Pants cannot infer owners for the following imports in the target kittl/libs/base/tests/conftest.py:../base:
* pytest (line: 5)
These imports are not in the resolve used by the target (`base`), but they were present in other resolves:
* pytest: 'python_default' from //:reqs#pytest
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.17/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
13:46:29.11 [WARN] Pants cannot infer owners for the following imports in the target kittl/libs/fancy/tests/conftest.py:../fancy:
* pytest (line: 5)
These imports are not in the resolve used by the target (`fancy`), but they were present in other resolves:
* pytest: 'python_default' from //:reqs#pytest
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.17/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
13:46:29.11 [WARN] Pants cannot infer owners for the following imports in the target kittl/libs/fancy/adder3.py:
* kittl.libs.base.adder2.add2 (line: 3)
These imports are not in the resolve used by the target (`fancy`), but they were present in other resolves:
* kittl.libs.base.adder2.add2: 'base' from kittl/libs/base/adder2.py
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.17/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
13:46:35.75 [INFO] Canceled: Building pytest.pex from <resource://pants.backend.python.subsystems/pytest.lock>
13:46:36.98 [INFO] Completed: Building requirements.pex
13:46:46.92 [INFO] Completed: Building pytest.pex from <resource://pants.backend.python.subsystems/pytest.lock>
13:46:48.25 [INFO] Completed: Building local_dists.pex
13:46:52.63 [INFO] Completed: Building pytest_runner.pex
13:46:55.90 [INFO] Completed: Run Pytest - kittl/libs/base/tests/test_base.py - succeeded.
13:46:56.03 [ERROR] Completed: Run Pytest - kittl/libs/fancy/tests/test_fancy.py - failed (exit code 2).
============================= test session starts ==============================
platform darwin -- Python 3.11.1, pytest-7.0.1, pluggy-1.0.0
rootdir: /private/var/folders/y2/6t5bbk554wv5h6w_qlgpcpnm0000gr/T/pants-sandbox-IS7APv
plugins: xdist-2.5.0, forked-1.6.0, cov-3.0.0
collected 0 items / 1 error
==================================== ERRORS ====================================
____________ ERROR collecting kittl/libs/fancy/tests/test_fancy.py _____________
ImportError while importing test module '/private/var/folders/y2/6t5bbk554wv5h6w_qlgpcpnm0000gr/T/pants-sandbox-IS7APv/kittl/libs/fancy/tests/test_fancy.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Users/andreas.stenius/.pyenv/versions/3.11.1/lib/python3.11/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
kittl/libs/fancy/tests/test_fancy.py:5: in <module>
from kittl.libs.base.adder2 import add2
E ModuleNotFoundError: No module named 'kittl.libs.base'
- generated xml file: /private/var/folders/y2/6t5bbk554wv5h6w_qlgpcpnm0000gr/T/pants-sandbox-IS7APv/kittl.libs.fancy.tests.test_fancy.py.xml -
=========================== short test summary info ============================
ERROR kittl/libs/fancy/tests/test_fancy.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.08s ===============================
✓ kittl/libs/base/tests/test_base.py succeeded in 3.21s.
✕ kittl/libs/fancy/tests/test_fancy.py failed in 3.34s.
errno:2
zsh ~/src/github/pietrobolcato/pants-monorepo-test main ? 13:46
❯ pants generate-lockfiles
13:49:34.16 [INFO] Completed: Generate lockfile for base
13:49:48.06 [INFO] Completed: Generate lockfile for python_default
13:49:48.07 [INFO] Wrote lockfile for the resolve `base` to kittl/libs/base/base.lock
13:49:48.07 [INFO] Wrote lockfile for the resolve `fancy` to kittl/libs/fancy/fancy.lock
13:49:48.07 [INFO] Wrote lockfile for the resolve `python_default` to python_default.lock
Lockfile diff: kittl/libs/base/base.lock [base]
== Removed dependencies ==
numpy 1.25.2
Lockfile diff: python_default.lock [python_default]
== Added dependencies ==
numpy 1.25.2
zsh ~/src/github/pietrobolcato/pants-monorepo-test main !? 13:49
❯ pants test ::
13:49:56.13 [INFO] Canceled: Building 1 requirement for requirements.pex from the kittl/libs/base/base.lock resolve: pytest~=7.1.3
13:49:56.13 [INFO] Canceled: Building 1 requirement for requirements.pex from the kittl/libs/fancy/fancy.lock resolve: pytest~=7.1.3
13:49:59.27 [INFO] Completed: Building 1 requirement for requirements.pex from the python_default.lock resolve: pytest~=7.1.3
13:50:02.82 [INFO] Completed: Building pytest_runner.pex
13:50:05.81 [INFO] Completed: Run Pytest - kittl/libs/base/tests/test_base.py - succeeded.
13:50:05.90 [INFO] Completed: Run Pytest - kittl/libs/fancy/tests/test_fancy.py - succeeded.
✓ kittl/libs/base/tests/test_base.py succeeded in 2.98s.
✓ kittl/libs/fancy/tests/test_fancy.py succeeded in 3.06s.
zsh ~/src/github/pietrobolcato/pants-monorepo-test main !? 13:50
❯
curved-television-6568
09/11/2023, 5:51 PMdiff --git a/kittl/libs/base/BUILD b/kittl/libs/base/BUILD
index b955ff8..8012b86 100644
--- a/kittl/libs/base/BUILD
+++ b/kittl/libs/base/BUILD
@@ -1,10 +1,10 @@
python_sources(
- resolve="base",
+ # resolve="base",
sources=["**/*.py"],
)
python_requirements(
name="reqs",
source="requirements.txt",
- resolve="base",
-)
\ No newline at end of file
+ # resolve="base",
+)
diff --git a/kittl/libs/base/tests/BUILD b/kittl/libs/base/tests/BUILD
index 4c25759..ad53575 100644
--- a/kittl/libs/base/tests/BUILD
+++ b/kittl/libs/base/tests/BUILD
@@ -1,5 +1,5 @@
python_tests(
name="tests",
- resolve="base",
+ # resolve="base",
sources=["test_*.py"],
)
diff --git a/kittl/libs/fancy/BUILD b/kittl/libs/fancy/BUILD
index 7eb7647..dc81270 100644
--- a/kittl/libs/fancy/BUILD
+++ b/kittl/libs/fancy/BUILD
@@ -1,10 +1,10 @@
python_sources(
- resolve="fancy",
+ # resolve="fancy",
sources=["**/*.py"],
)
python_requirements(
name="reqs",
source="requirements.txt",
- resolve="fancy",
-)
\ No newline at end of file
+ # resolve="fancy",
+)
diff --git a/kittl/libs/fancy/tests/BUILD b/kittl/libs/fancy/tests/BUILD
index 350d228..c5e8085 100644
--- a/kittl/libs/fancy/tests/BUILD
+++ b/kittl/libs/fancy/tests/BUILD
@@ -1,5 +1,5 @@
python_tests(
name="tests",
- resolve="fancy",
+ # resolve="fancy",
sources=["test_*.py"],
)
curved-television-6568
09/11/2023, 5:53 PMconftest.py
files will be included in the test runs…proud-byte-81916
09/11/2023, 6:54 PMconftest.py!
proud-byte-81916
09/11/2023, 6:54 PMcurved-television-6568
09/11/2023, 7:04 PMcurved-television-6568
09/11/2023, 7:04 PMparametrize
curved-television-6568
09/11/2023, 7:05 PMfiles
target, not a python_sources
one, so that’s fine.curved-television-6568
09/11/2023, 7:06 PMproud-byte-81916
09/11/2023, 7:49 PMproud-byte-81916
09/12/2023, 10:47 AMshell_command(
command="bash run_chalice_local.sh",
tools=["chalice"],
)
how can i run this through pants? appreciate your help!proud-byte-81916
09/12/2023, 10:47 AMcurved-television-6568
09/12/2023, 1:51 PMrun_shell_command
target. https://www.pantsbuild.org/docs/run-shell-commands#the-run_shell_command-target
something like:
run_shell_command(
name="chalice",
command="./run_chalice_local.sh",
tools=["chalice"],
execution_dependencies=[":run_chalice_local.sh"],
)
then:
$ pants run ../dir:chalice -- <chalice script args>
curved-television-6568
09/12/2023, 1:51 PMproud-byte-81916
09/12/2023, 1:54 PMcurved-television-6568
09/12/2023, 1:57 PMproud-byte-81916
09/13/2023, 9:37 AMparametrize
) - or in other words it would be great to have the jup notebook that loads dependencies like pants run, so eg when I execute:
pants run kittl/projects/my_project/main.py
I tried adding to my BUILD `pex_binary`:
python_sources(
name="my_project",
resolve="my_project",
)
python_requirements(
name="reqs",
source="requirements.txt",
resolve="my_project",
)
pex_binary(
name="my_project_bin"
)
And loading with the magic:
%pants_load kittl/projects/my_project
But it fails because it can't find the right version of python in the path of the notebook, specifically it's not looking at the pyenv root
folder
Would you have any suggestion to fix this? Thanks so much once again! Really appreciate your help! 🙂curved-television-6568
09/13/2023, 2:26 PMbitter-ability-32190
09/13/2023, 2:30 PMproud-byte-81916
09/13/2023, 2:33 PMproud-byte-81916
09/13/2023, 2:46 PMrun_shell_command
it works in itself so thanks so much for that! but unfortunately it doesn't do what we need - we are trying to run "chalice local" and "chalice deploy" (docs) to build and deploy a lambda function
These commands are based on python and need to access all the dependencies of the resolve, exactly as if i was running pytest in a sense
Using run run_shell_command
with chalice doesn't work because dependencies are not injected - does any solution come to mind by any chance?
Appreciate it a lot! 🙏🙏curved-television-6568
09/13/2023, 3:01 PMbitter-ability-32190
09/13/2023, 4:02 PMancient-vegetable-10556
09/13/2023, 6:23 PMancient-vegetable-10556
09/13/2023, 6:24 PMpython -m
?proud-byte-81916
09/13/2023, 6:26 PMproud-byte-81916
09/13/2023, 6:35 PMproud-byte-81916
09/13/2023, 6:35 PMbitter-ability-32190
09/13/2023, 6:47 PMproud-byte-81916
09/13/2023, 7:01 PM