Hi all,
any reason why the Tip option in the drop down menu is not available once clicking +Add button?
Thanks.
Francis
Hi all,
any reason why the Tip option in the drop down menu is not available once clicking +Add button?
Thanks.
Francis
Same issue as shown here:
Hello @FrancisThibault,
You may have to initialize the Tip activity before you can select it. Can you please try running the following python script, filling in the appropriate admin credentials? You will need to download the LAMP-core module to run this, for example with pip install LAMP-core
import sys
import LAMP
ACTIVITY_SPEC_LIST = [
"lamp.3d_figure_copy",
"lamp.balloon_risk",
"lamp.breathe",
"lamp.cats_and_dogs",
"lamp.cats_and_dogs_new",
"lamp.dbt_diary_card",
"lamp.digit_span",
"lamp.jewels_a",
"lamp.jewels_b",
"lamp.journal",
"lamp.nback",
"lamp.nback_new",
"lamp.pop_the_bubbles",
"lamp.scratch_image",
"lamp.serial7s",
"lamp.simple_memory",
"lamp.spatial_span",
"lamp.spin_wheel",
"lamp.survey",
"lamp.temporal_order",
"lamp.tips",
"lamp.trails_b",
"lamp.trails_b_dot_touch",
"lamp.trails_b_new",
"lamp.visual_association",
"lamp.recording"
]
SENSOR_SPEC_LIST = [
"lamp.accelerometer",
"lamp.accelerometer.motion",
"lamp.analytics",
"lamp.blood_pressure",
"lamp.bluetooth",
"lamp.calls",
"lamp.screen_state",
"lamp.distance",
"lamp.flights",
"lamp.gps",
"lamp.gps.contextual",
"lamp.gyroscope",
"lamp.heart_rate",
"lamp.height",
"lamp.magnetometer",
"lamp.respiratory_rate",
"lamp.segment",
"lamp.sleep",
"lamp.sms",
"lamp.steps",
"lamp.weight",
"lamp.wifi",
]
print("[LAMP Platform] ActivitySpec & SensorSpec Initialization Tool")
print("You must enter your username, password, and server address to continue installation.")
print("Username: admin [CANNOT BE CHANGED]")
LAMP.connect("admin", input("Password: "), input("Server Address: "))
for spec in ACTIVITY_SPEC_LIST:
try:
print(f"Creating ActivitySpec '{spec}'...")
LAMP.ActivitySpec.create({ "name": spec })
except:
print(f"Could not create {spec}. It may already exist")
for spec in SENSOR_SPEC_LIST:
try:
print(f"Creating SensorSpec '{spec}'...")
LAMP.SensorSpec.create({ "name": spec })
except:
print(f"Could not create {spec}. It may already exist")
This function will attempt to create all the commonly used LAMP activities and sensors, after which you should see the tip activity become available. (You may have to refresh your page or clear your cache for this to take effect, however)
Of course, if you encounter any issues running this script, or if does not produce your desired result, please let me know.
Best,
Luke
EDIT (Feb., 23, 2021): I changed the ‘lamp.device_state’ sensor to ‘lamp.screen_state’ as this is the correct name of the Sensor
Thanks a lot @LukeS , very appreciated!
Hi @LukeS , I have an issue with the script. Is the server address the address of the api server, which in my case is: localhost or 127.0.0.1. I always got “it may already exist” but it is not the case. Any ideas why? It seems that it failed to connect while debugging. Thanks again
Hi @FrancisThibault, yes, the server address should be the address of your api server.
The “it may already exist” error just indicates that some error occurred while attempting to create a spec. For most people that could indicate a spec already exists, but in your case it could be a sign that you are failing to connect.
Could you try running this updated script which will just attempt to add the tip spec?
import sys
import LAMP
ACTIVITY_SPEC_LIST = ["lamp.tips"]
print("[LAMP Platform] ActivitySpec & SensorSpec Initialization Tool")
print("You must enter your username, password, and server address to continue installation.")
print("Username: admin [CANNOT BE CHANGED]")
LAMP.connect("admin", input("Password: "), input("Server Address: "))
for spec in ACTIVITY_SPEC_LIST:
print(f"Creating ActivitySpec '{spec}'...")
LAMP.ActivitySpec.create({ "name": spec })
If this fails (which it probably will based on your initial experience), could you provide the specific error and stack trace? This will help us figure out the exact reason this command isn’t executing.
Best,
Luke
Hi @LukeS , thanks for being very responsive. This is the stack trace I got:
C:\ProgramData\miniforge3\envs\mindLamp_Android\python.exe “C:\Program Files\JetBrains\PyCharm 2020.2.2\plugins\python\helpers\pydev\pydevd.py” --multiproc --qt-support=auto --client 127.0.0.1 --port 61237 --file D:/git/BIDMCDigitalPsychiatry/mindlamp-backend-setup/populate_sensors_and_activities.py
C:\Program Files\JetBrains\PyCharm 2020.2.2\plugins\python\helpers\pydev\pydevd.py:1844: DeprecationWarning: currentThread() is deprecated, use current_thread() instead
dummy_thread = threading.currentThread()
Connected to pydev debugger (build 212.4746.96)
[LAMP Platform] ActivitySpec & SensorSpec Initialization Tool
You must enter your username, password, and server address to continue installation.
Username: admin [CANNOT BE CHANGED]
Password: >? XXX
Server Address: >? 127.0.0.1
Creating ActivitySpec ‘lamp.tips’…
Traceback (most recent call last):
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 1010, in validate_conn
conn.connect()
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connection.py”, line 416, in connect
self.sock = ssl_wrap_socket(
File "C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\util\ssl.py", line 453, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\util\ssl.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\ssl.py”, line 512, in wrap_socket
return self.sslsocket_class._create(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\ssl.py”, line 1070, in _create
self.do_handshake()
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\ssl.py”, line 1341, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\LAMP\rest.py”, line 162, in request
r = self.pool_manager.request(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\request.py”, line 78, in request
return self.request_encode_body(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\request.py”, line 170, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\poolmanager.py”, line 375, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 783, in urlopen
return self.urlopen(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 783, in urlopen
return self.urlopen(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 783, in urlopen
return self.urlopen(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “C:\ProgramData\miniforge3\envs\mindLamp_Android\lib\site-packages\urllib3\util\retry.py”, line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘127.0.0.1’, port=443): Max retries exceeded with url: /activity_spec (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)’)))
python-BaseException
Seems to be related to the SSL Certificate Verification. On our side, we have created a certificate authority and we have accessed to the api server through Chrome browser without any issue.
Thanks for your support.
Hi @FrancisThibault,
I checked with other members of our team – the consensus was that this problem is due to you hosting LAMP locally. With your current configuration you won’t be able to get SSL which will cause LAMP API requests to fail as they MUST have HTTPS for security.
In order to proceed you would need to procure a domain name with the proper SSL certificates. I’m sorry I can’t be more help with this specific issue but please let me know if I can give any other info or advice.
Best,
Luke