Has anyone by any chance ran into this stack trace...
# general
b
Has anyone by any chance ran into this stack trace:
Copy code
platform darwin -- Python 3.6.5, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /private/var/folders/t2/h7w2qkz95jj9pwg9w87q7tc00000gp/T/process-executionRbwpkq
plugins: cov-3.0.0
collected 0 items / 1 error

==================================== ERRORS ====================================
_ ERROR collecting python/monitor_spot_instances/tests/test_monitor_spot_instances.py _
ImportError while importing test module '/private/var/folders/t2/h7w2qkz95jj9pwg9w87q7tc00000gp/T/process-executionRbwpkq/python/monitor_spot_instances/tests/test_monitor_spot_instances.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Users/cris/.pyenv/versions/3.6.5/lib/python3.6/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
python/monitor_spot_instances/tests/test_monitor_spot_instances.py:4: in <module>
    import boto3
E   ModuleNotFoundError: No module named 'boto3'
- generated xml file: /private/var/folders/t2/h7w2qkz95jj9pwg9w87q7tc00000gp/T/process-executionRbwpkq/python.monitor_spot_instances.tests.test_monitor_spot_instances.py.xml -
=========================== short test summary info ============================
ERROR python/monitor_spot_instances/tests/test_monitor_spot_instances.py
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.15s ===============================



š„‚ python/monitor_spot_instances/tests/test_monitor_spot_instances.py failed.
All my requirements (
boto
) reside within the
monitor_spot_instances
directory and have a
BUILD
file with
python_requirements()
generated in it
p
so you will want to run
./pants dependencies python/monitor_spot_instances/tests/test_monitor_spot_instances.py
to see a list of dependencies for this test as pants sees them.
h
Does your test directly
import boto3
?
b
yea yes it does. it seems to mock some
boto3
client calls
so the author had to import
boto3
h
So Pants's dependency inference should be able to pick that up, hmm
b
@polite-garden-50641 onnit running the dependencies and ping this thread back
h
I do recommend putting the
python_requirements()
target in the same directory as the
requirements.txt
it wraps
Dep inference should do the rest
b
yea so the
monitor_spot_instances
has the
requirements.txt
and also holds the
python_requirements()
and then beyond that i have a
src
and
test
folder with
python_sources
and
python_tests
respectively
h
Got it
Are there other
requirements.txt
in your repo? Do they also contain boto3?
Are you seeing any WARN logs about multiple requirements providing the same symbol?
b
yeah
when i run the dependency command specifically
Copy code
Instead, use `python_sources`, which behaves the same. Run `./pants update-build-files` to automatically fix your BUILD files.
16:11:51.06 [WARN] The target python/monitor_spot_instances/tests/test_monitor_spot_instances.py imports `boto3`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['python/aws_config_compliance:boto3', 'python/hs_pending_instance_lambda:boto3', 'python/mongodb_atlas_audit_logs:boto3', 'python/monitor_spot_instances/src:boto3', 'python/monitor_spot_instances/tests:boto3', 'python/monitor_spot_instances:boto3'].
Ah Both of you were right
i got it to work. The problem was the between the chair and keyboard..
šŸ˜‚ 1
šŸŽ‰ 1
i had the
python_requirements()
in the subproject root folder as well as the
src
and
tests
folder
once i got rid of that ran
./pants dependenciesā€¦
the tests worked. also did a
./pants update-build-files
party time
h
Great!