Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zerodeploy not working with my custom service #454

Open
arnav224 opened this issue Aug 22, 2021 · 2 comments
Open

zerodeploy not working with my custom service #454

arnav224 opened this issue Aug 22, 2021 · 2 comments
Assignees
Labels
To Start Description reviewed and a maintainer needs "to start" triage

Comments

@arnav224
Copy link

Can't run rpyc zerodeploy with basic service I define.
All the examples I found for zerodeploy uses conn = server.classic_connect() which uses some default rpyc service.

I want to deploy my custom service in the remote machine. I tried this code:

import sys
import rpyc
from rpyc.utils.zerodeploy import DeployedServer
from plumbum import SshMachine

HOST_NAME = "****"
USER_NAME = "****"

# $ ssh-keygen -t ed25519
# $ ssh-copy-id user@hostname
ssh_machine = SshMachine(host=HOST_NAME, user=USER_NAME, keyfile='~/.ssh/id_ed25519')

server = DeployedServer(remote_machine=ssh_machine)

class MyService(rpyc.ClassicService):
    ALIASES = ["foo", "bar"]
    def exposed_add(self, a, b):
        return a + b

config = {"allow_all_attrs": True, 'allow_exposed_attrs': True}

# Here I'm trying to use My service
conn = server.connect(service=MyService, config=config)

print(f'1. rpyc.__version__={rpyc.__version__}')
print(f'2. local platform: {sys.platform}')
print(f'3. local python version: {sys.version}')

print(f'4. aliases: {conn.root.get_service_aliases()}')
print(f'5. remote platform: {conn.modules.sys.platform}')
print(f'6. remote python version: {conn.modules.sys.version}')
print(f'7. {conn.root.add(4, 7)}')

server.close()

And I'm getting error for the last (7) print:

1. rpyc.__version__=(5, 0, 1)
2. local platform: linux
3. local python version: 3.7.6 (default, Jan 30 2020, 10:29:04) 
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
4. aliases: ('SLAVE',)
5. remote platform: linux
6. remote python version: 3.7.6 (default, Jan 30 2020, 10:29:04) 
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]
Traceback (most recent call last):
  File "/home/****/pythonPlayGround/rpyc_try/rpyc_try.py", line 53, in <module>
    print(f'7. {conn.root.add(4, 7)}')
  File "/home/****/.local/lib/python3.7/site-packages/rpyc/core/netref.py", line 153, in __getattr__
    return syncreq(self, consts.HANDLE_GETATTR, name)
  File "/home/****/.local/lib/python3.7/site-packages/rpyc/core/netref.py", line 63, in syncreq
    return conn.sync_request(handler, proxy, *args)
  File "/home/****/.local/lib/python3.7/site-packages/rpyc/core/protocol.py", line 473, in sync_request
    return self.async_request(handler, *args, timeout=timeout).value
  File "/home/****/.local/lib/python3.7/site-packages/rpyc/core/async_.py", line 102, in value
    raise self._obj
AttributeError: 'SlaveService' object has no attribute 'add'

========= Remote Traceback (1) =========
Traceback (most recent call last):
  File "/home/****/tmp.PPeuiZhBA8/rpyc/core/protocol.py", line 324, in _dispatch_request
    res = self._HANDLERS[handler](self, *args)
  File "/home/****/tmp.PPeuiZhBA8/rpyc/core/protocol.py", line 608, in _handle_getattr
    return self._access_attr(obj, name, (), "_rpyc_getattr", "allow_getattr", getattr)
  File "/home/****/tmp.PPeuiZhBA8/rpyc/core/protocol.py", line 536, in _access_attr
    return accessor(obj, name, *args)
AttributeError: 'SlaveService' object has no attribute 'add'

Judging by the aliases: ('SLAVE',) I would think that the remote service is not MyService, but if I change MyService to inherit from rpyc.Service instead of rpyc.ClassicService I'm getting the error AttributeError: 'Connection' object has no attribute 'modules' for the second print, so it is MyService (but it's not working as expected).

Also when I override the on_connect() in MyService it's not running.

backgroung:
I want my code to be able to run on any remote machine with no prerequisites.
My other option (which I used before) is to send a server_code.py file and run it (all using SSH), the server_code will run MyService like this: server = rpyc.ThreadedServer(MyService, ..).
I don't like this solution. I need to deal with pip install rpyc, with the temp directory and manage the connection myself. I don't think this is the right way.
rpyc zerodeploy should deal with all of it for me, right?

@arnav224
Copy link
Author

arnav224 commented Sep 2, 2021

Do you know if anyone in the world has really used zerodeploy? Or is it broken and I should give up? I would think it's a problem in my side but I did not find anyone who used it, in all GitHub, isn't it weird?

@comrumino comrumino self-assigned this Sep 29, 2021
@comrumino
Copy link
Collaborator

I assure you that zerodeploy has been used and loved by some users. #377 show that users have had success with it---I'd go through their blog on remote testing. I'll see if I can carve out time soon.

@comrumino comrumino added the To Start Description reviewed and a maintainer needs "to start" triage label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
To Start Description reviewed and a maintainer needs "to start" triage
Projects
None yet
Development

No branches or pull requests

2 participants