reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Cannot deploy app with "paramiko" as dependency

Open ali-zakaria opened this issue 3 months ago β€’ 5 comments

Describe the bug Cannot deploy app with "paramiko" as dependency.

Getting this error when running the application

2024-05-12 01:30:04.498689 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save_dict(pickler, obj) | None | None
2024-05-12 01:30:04.498689 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 971, in save_dict | None | None
2024-05-12 01:30:04.498690 Romance Daylight Time | rxh-prod-botmanagerwebapp |      self._batch_setitems(obj.items()) | None | None
2024-05-12 01:30:04.499024 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 997, in _batch_setitems | None | None
2024-05-12 01:30:04.499029 Romance Daylight Time | rxh-prod-botmanagerwebapp |      save(v) | None | None
2024-05-12 01:30:04.499032 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 414, in save | None | None
2024-05-12 01:30:04.499033 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save(self, obj, save_persistent_id) | None | None
2024-05-12 01:30:04.499034 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 603, in save | None | None
2024-05-12 01:30:04.499035 Romance Daylight Time | rxh-prod-botmanagerwebapp |      self.save_reduce(obj=obj, *rv) | None | None
2024-05-12 01:30:04.499036 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 717, in save_reduce | None | None
2024-05-12 01:30:04.499036 Romance Daylight Time | rxh-prod-botmanagerwebapp |      save(state) | None | None
2024-05-12 01:30:04.499036 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 414, in save | None | None
2024-05-12 01:30:04.499037 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save(self, obj, save_persistent_id) | None | None
2024-05-12 01:30:04.499037 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 560, in save | None | None
2024-05-12 01:30:04.499038 Romance Daylight Time | rxh-prod-botmanagerwebapp |      f(self, obj)  # Call unbound method with explicit self | None | None
2024-05-12 01:30:04.499038 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 1217, in save_module_dict | None | None
2024-05-12 01:30:04.499039 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save_dict(pickler, obj) | None | None
2024-05-12 01:30:04.499039 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 971, in save_dict | None | None
2024-05-12 01:30:04.499040 Romance Daylight Time | rxh-prod-botmanagerwebapp |      self._batch_setitems(obj.items()) | None | None
2024-05-12 01:30:04.499040 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 997, in _batch_setitems | None | None
2024-05-12 01:30:04.499041 Romance Daylight Time | rxh-prod-botmanagerwebapp |      save(v) | None | None
2024-05-12 01:30:04.499041 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/home/reflexuser/venv/lib/python3.8/site-packages/dill/_dill.py", line 414, in save | None | None
2024-05-12 01:30:04.499042 Romance Daylight Time | rxh-prod-botmanagerwebapp |      StockPickler.save(self, obj, save_persistent_id) | None | None
2024-05-12 01:30:04.499042 Romance Daylight Time | rxh-prod-botmanagerwebapp |    File "/usr/local/lib/python3.8/pickle.py", line 578, in save | None | None
2024-05-12 01:30:04.499043 Romance Daylight Time | rxh-prod-botmanagerwebapp |      rv = reduce(self.proto) | None | None
2024-05-12 01:30:04.499043 Romance Daylight Time | rxh-prod-botmanagerwebapp |  TypeError: cannot pickle 'cryptography.hazmat.bindings._rust.openssl.rsa.RSAPrivateKey' object | None | None

To Reproduce

Deploy application with this requirement.txt

reflex==0.4.9
cryptography==42.0.7
paramiko==3.4.0

Expected behavior Application should run like in localhost:3000 mode

Specifics (please complete the following information):

  • Python Version: 3.8.10
  • Reflex Version: 0.4.9
  • OS: Windows 10
  • Browser (Optional): Chrome

ali-zakaria avatar May 11 '24 23:05 ali-zakaria

Work-around: Use subprocess and native ssh instead of paramiko

        cmd = 'ssh -o StrictHostKeyChecking=accept-new -i "%s" %s@%s "%s"' % (ssh.server.pkeyPath, ssh.server.username, ssh.server.hostname, cmd_to_execute)
        p = subprocess.Popen(cmd,
                           shell=True,
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE)
        ssh_stdout, ssh_stderr = p.communicate()

ali-zakaria avatar May 12 '24 02:05 ali-zakaria

Are you keeping any ssh related objects in the State? That pickling error is coming from reflex trying to pickle the state for redis (prod mode)

masenf avatar May 12 '24 23:05 masenf