I'm writing some tests for code that calls TensorFlow 2.0.1. This library imports the imp module, which triggers a deprecation warning when I run pytest. I'm trying to muffle this warning, but without success.
This is my testing module:
import pytest
import warnings
from fclib.models.dilated_cnn import create_dcnn_model
def test_create_dcnn_model():
with pytest.deprecated_call():
create_dcnn_model(seq_len=1, max_cat_id=[30, 120]) # calls tensorflow.keras code
The output from pytest test_dcnn.py is
[...]
======================================== FAILURES ========================================
_________________________________ test_create_dcnn_model _________________________________
def test_create_dcnn_model():
with pytest.deprecated_call():
> create_dcnn_model(seq_len=1, max_cat_id=[30, 120])
E Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>, <class 'PendingDeprecationWarning'>) was emitted. The list of emitted warnings is: [].
fclib/tests/test_dcnn.py:11: Failed
---------------------------------- Captured stderr call ----------------------------------
2020-07-07 03:15:03.162833: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2020-07-07 03:15:03.174538: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2095190000 Hz
2020-07-07 03:15:03.177318: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55ef3370ff20 executing computations on platform Host. Devices:
2020-07-07 03:15:03.177351: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version
==================================== warnings summary ====================================
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================ short test summary info =================================
FAILED fclib/tests/test_dcnn.py::test_create_dcnn_model - Failed: DID NOT WARN. No warn...
============================== 1 failed, 1 warning in 2.39s ==============================
So it complains that there was no warning, and yet the printed output says that there was a warning. What's happening here?
If I remove the with pytest.deprecated_call() line, I get:
def test_create_dcnn_model():
# with pytest.deprecated_call():
create_dcnn_model(seq_len=1, max_cat_id=[30, 120])
================================== test session starts ===================================
platform linux -- Python 3.6.10, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /data/forecasting/fclib
collected 1 item
fclib/tests/test_dcnn.py . [100%]
==================================== warnings summary ====================================
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================== 1 passed, 1 warning in 2.00s ==============================
So it passes, but the warning message is still present. How can I get rid of that message completely?
Related
I have installed the plugin from github/joshdoe/gst-plugins-vision and using the Pylon gst.
I get error when I try to use the gstreamer plugin in python.
Any ideas? I have asked the question in github forum too, but since its more python related I figured I get a better chance of answer here.
CODE:
import cv2
import sys
import gi
from gi.repository import GObject, Gst
def open_cam(width, height):
# We want to set width and height here, otherwise we could just do:
# return cv2.VideoCapture(dev)
gst_str = ('pylonsrc config-file=acA2040.pfs! '
'queue ! '
'videoconvert ! appsink').format(width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
def main():
print(cv2.__version__)
gi.require_version('Gst', '1.0')
Gst.debug_set_active(True)
Gst.debug_set_default_threshold(3)
cap = open_cam(2048, 2048)
if not cap.isOpened():
sys.exit("Failed to open camera!")
Gst.init(None)
if __name__== "__main__":
main()
ERROR:
sudo python3 main.py
main.py:4: PyGIWarning: Gst was imported without specifying a version first. Use gi.require_version('Gst', '1.0') before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gst
4.2.0
0:00:00.441833101 18495 0x2d48440 pylonsrc gstpylonsrc.c:3675:gst_pylonsrc_load_configuration:<pylonsrc0> PylonC error: PylonC error #c2000001 'Could not load features from file.' (0xc2000001).
0:00:00.441950413 18495 0x2d48440 pylonsrc gstpylonsrc.c:3675:gst_pylonsrc_load_configuration:<pylonsrc0> PylonC error: Function 'PylonFeaturePersistenceLoad' failed in source file '../../../../../../../Pylon/PylonC/PylonC/PylonC.cpp' line #5187
Caused by an exception thrown from source file '../../../../../../Pylon/PylonUtility/FeaturePersistence.cpp' line #503.
The file could not opened for reading.
0:00:00.444235795 18495 0x2d48440 WARN basesrc gstbasesrc.c:3468:gst_base_src_start:<pylonsrc0> error: Failed to start
0:00:00.444327001 18495 0x2d48440 WARN basesrc gstbasesrc.c:3824:gst_base_src_activate_push:<pylonsrc0> Failed to start in push mode
0:00:00.444374673 18495 0x2d48440 WARN GST_PADS gstpad.c:1142:gst_pad_set_active:<pylonsrc0:src> Failed to activate pad
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (1758) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module pylonsrc0 reported: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Failed to open camera!
I've followed Head First Python 2nd Edition and a pep8 compliance testing is demonstrated in chapter 4.
When running py.test --pep8 searchV.py gives error
appdata\local\programs\python\python38\lib\site-packages\pep8.py:110: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
===============test session starts =========================================
platform win32 -- Python 3.8.6, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
rootdir: D:\work\py-modules
plugins: pep8-1.0.6
collected 0 items / 1 error
=============== ERRORS =======================================================
_______________ERROR collecting test session ____
Direct construction of Pep8Item has been deprecated, please use Pep8Item.from_parent.
See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.
==========short test summary info ===============
ERROR
!!!!!!!!!!!!!!!!!!!!Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!
Here's the code in serachV.py
def search_letter(phrase: str , letter:str='aeiou')->set:
""" Serach for letter in phrase"""
return set(letter).intersection(set(phrase))
Not sure why no items are collected ?
Tried pep8 searchV.py instead of Instead of py.test --pep8 searchV.py and it worked.
But pep8 has been renamed to pycodestyle (GitHub issue #466) . Use of the pep8 tool will be removed in a future release.
So , I used pycodestyle and it worked !
pycodestyle searchV.py
I am running ModelSim SE-64 10.5 on windows 10 and when I wanna simulate any module I run into the following error:
vsim -gui work.registerFileTB -novopt
# vsim -gui work.registerFileTB -novopt
# Start time: 15:20:14 on Dec 23,2020
# ** Error (suppressible): (vsim-12110) All optimizations are disabled because the -novopt option is in effect. This will cause your simulation to run very slowly. If you are using this switch to preserve visibility for Debug or PLI features, please see the User's Manual section on Preserving Object Visibility with vopt. -novopt option is now deprecated and will be removed in future releases.
# Error loading design
# End time: 15:20:14 on Dec 23,2020, Elapsed time: 0:00:00
# Errors: 1, Warnings: 0
The error message is self explanatory—remove the -novopt switch. Check the user manual for what you should use instead
After starting the simulation with optimization, I could not see the objects. Without optimization there is the same error.
Set enable optimization.
Open "Optimization options..."
In the tab Visibility: set "Apply full visibility to all modules"
When execute my program in python, I have a problem with a build only in "cl.device_type.GPU" but "cl.device_type.CPU" don't have problems
import pyopencl as cl
Mi_Contexto=cl.Context(devices=[cl.get_platforms()[0].get_devices(device_type=cl.device_type.GPU)[0]])
Mi_Cola_de_comandos=cl.CommandQueue(Mi_Contexto)
Mi_programa=cl.Program(Mi_Contexto,'''
__kernel void threads_in_pyopencl(void){
printf("HOLA\\n");
while(1<10){}
}
''').build(options=[])
*Exception has occurred: RuntimeError
clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE - clBuildProgram failed: BUILD_PROGRAM_FAILURE
Build on <pyopencl.Device 'AMD Radeon Pro 555 Compute Engine' on 'Apple' at 0x1021c00>:
SC failed. No reason given.
(options: -I /usr/local/lib/python3.7/site-packages/pyopencl/cl)
(source saved as /var/folders/cj/v6tpwrhj58j0jc2s0zgmp1wr0000gn/T/tmpmqfa6yow.cl)
File "/Users/gustavo/Python projects/PyOpenCL mis programas/threads/PyOpenCL threads.py", line 15, in
''').build(options=[])*
So, I changed to the next kernel, with the same flag "cl.device_type.GPU" and the problem disappeared. I don't know what is the problem
Mi_programa=cl.Program(Mi_Contexto,'''
__kernel void threads_in_pyopencl(void){
while(1<10){}
printf("HOLA\\n");
}
''').build(options=[])
P.D. I have Mac OS Catalina without conda, I installed PyOpenCL with pip.
I can't verify it as I do not have an AMD / Radeon card but I guess you have to enable the proper extension with
#pragma OPENCL EXTENSION cl_amd_printf : enable
See also the following answer
This is what I get when I try to connect Software RTL simulation and OpenOCD:
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00068-ge1e63ef30 (2020-03-16-05:57)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Info : Initializing remote_bitbang driver
Info : Connecting to localhost:38000
Info : remote_bitbang driver initialized
Info : This adapter doesn't support configurable speed
Error: fflush: Broken pipe
Error: read: count=-1, error=Broken pipe
Error: Trying to use configured scan chain anyway...
Error: fflush: Broken pipe
Error: fflush: Broken pipe
Warn : Bypassing JTAG setup events due to errors
Error: fflush: Broken pipe
Error: fflush: Broken pipe
Error: failed jtag scan: -4
Error: Unsupported DTM version: 12
Info : Listening on port 3333 for gdb connections
Error: Target not examined yet
Error: Unsupported DTM version: 12
Error: fflush: Broken pipe
Error: failed: -4
I applied the instructions at 8.2.2.1. Creating a DTM+JTAG Config.
The following is the content of OpenOCD config file:
interface remote_bitbang
remote_bitbang_host localhost
remote_bitbang_port 38000
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
gdb_report_data_abort enable
init
halt
And this is the command I use to run the simulation:
./simulator-chipyard-jtagRocketConfig +jtag_rbb_enable=1 --rbb-port=38000 <TESTNAME>
I managed to run OpenOCD.
This is the current content of OpenOCD config file:
adapter_khz 10000
interface remote_bitbang
remote_bitbang_host $::env(REMOTE_BITBANG_HOST)
remote_bitbang_port $::env(REMOTE_BITBANG_PORT)
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys $::env(WORK_AREA) -work-area-size 8096 -work-area-backup 1
gdb_report_data_abort enable
gdb_report_register_access_error enable
# Expose an unimplemented CSR so we can test non-existent register access
# behavior.
riscv expose_csrs 2288
riscv expose_custom 1,12345-12348
init
set challenge [riscv authdata_read]
riscv authdata_write [expr $challenge + 1]
halt
And this is how I run OpenOCD:
REMOTE_BITBANG_HOST=localhost REMOTE_BITBANG_PORT=38000 WORK_AREA=0x1212340000 openocd --command 'gdb_port 0' --command 'tcl_port disabled' --command 'telnet_port disabled' -f openocd.cfg
I also installed Verilator (v4.028).