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

Running botserver for local development #12669

Open
arthurpankiewicz opened this issue Jun 28, 2019 · 14 comments
Open

Running botserver for local development #12669

arthurpankiewicz opened this issue Jun 28, 2019 · 14 comments

Comments

@arthurpankiewicz
Copy link

I'm trying to setup an environment where I'm able to run a bot locally for either

  • zulip development(vagrant)
  • zulip produciton

My current workaround was pulling the zulip python-zulip-api, placing my bot in there, and using either the zulip-run-bot <bot> command or interacting via the zulip-terminal

I'd like to manage my bot separately in my git, without the need for all the extra bots/files found in python-zulip-api

Following the instrucitons here I've installed the zulip-botserver package, and my current project directory looks like:

zulip-mybot
  - readme.md
  - zulip_bots
    - bots
       - mybot

I have a production version of zulip running with an organization where I created a bot and downloaded it's zuliprc

When I run (from within zulip-mybot directory):

zulip-botserver --config-file /path/to/zuliprc

I receive the error: "Error: Bot "mybot" doesn't exist. Please make sure you have set up the botserverrc file correctly."

My zuliprc file looks like:

[mybot]
[email protected]
key=KEY
site=https://ORGNAME.zulipchat.com
token=TOKEN

I'm not even sure if this is the correct way to run for local dev/testing, but the goal is to not have to develop within the python-zulip-api and copy and paste working code to my git directory.

Thanks!

@zulipbot
Copy link
Member

Hello @zulip/server-bots members, this issue was labeled with the "area: bots" label, so you may want to check it out!

@timabbott
Copy link
Member

@arthurpankiewicz thanks for the report!

I suspect that the botserver code is just missing the nice logic for detecting the paths to out-of-tree bots that we use in e.g. zulip-run-bot.

@thedeveloperr
Copy link
Collaborator

@zulipbot claim

@arthurpankiewicz
Copy link
Author

@timabbott yeah I was getting some funky behaviour.

I edited the server.py to log the error, and it was trying to import a bot module at zulip_bots.zulip_bots.bot._______ and was failing, but if I went into my py3 console and ran the same import, it seemed to work.

If you require more information @thedeveloperr I can rerun my steps and provide some more context

@arthurpankiewicz
Copy link
Author

@thedeveloperr any status update on this?

@thedeveloperr
Copy link
Collaborator

@arthurpankiewicz I am sorry I am still reading the docs and code of this, this my first issue regarding this area and was also working on few other ongoing issues. So progress is a bit slow. I will try to fix this soon.

If you require more information @thedeveloperr I can rerun my steps and provide some more context

Sorry I missed notification of your previous message. I would like to have as much information regarding the issue as possible if you don't mind re-running. 😅

@zulipbot
Copy link
Member

zulipbot commented Jul 28, 2019

Hello @thedeveloperr, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.

You can reclaim this issue or claim any other issue by commenting @zulipbot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

@arthurpankiewicz
Copy link
Author

@thedeveloperr sorry I just returned from vacation, I can update with some extra info this weekend

@thedeveloperr
Copy link
Collaborator

@zulipbot claim

@arthurpankiewicz
Copy link
Author

@thedeveloperr

when I cloned python-zulip-api and followed the steps to set up environment and develop bots, when I run pip list, I have the following packages (when running the python-zulip-api env):

Package            Version   Location                                                        
------------------ --------- ----------------------------------------------------------------
zulip              0.6.1     /Users/arthur/workspace/python3/python-zulip-api/zulip          
zulip-bots         0.6.1     /Users/arthur/workspace/python3/python-zulip-api/zulip_bots     
zulip-botserver    0.6.1     /Users/arthur/workspace/python3/python-zulip-api/zulip_botserver

When I follow deploy instructions found here, installing the zulip python packages, when I run pip in a separate directory (where I am developing a standalone bot), running python3 -m pip list I have

Package           Version 
----------------- --------
zulip             0.6.0   
zulip-bots        0.6.0   
zulip-botserver   0.6.0 

with no location.
When I run zulip-run-bot <botname> --config-file /path/to/zuliprc in a venv after pip install zulip, I receive

ERROR: Could not load bot module. Exiting now.

@neiljp
Copy link
Contributor

neiljp commented Aug 5, 2019

@arthurpankiewicz Can you get your bot to run by specifying the path in place of the botname, wherever it is located?

One future approach which I proposed for this, which may make this simpler for you, is where you would install the zulip-bots package (eventually just from pypi, for now from git in a PR) and install your own bot package separately, with an appropriate element in setup.py which would register your bot's unique name for access by zulip-run-bot. I'm guessing that would help for deployment, but would appreciate your feedback. That PR is currently zulip/python-zulip-api/pull/517

My understanding is that the pip list differences are likely since a straight pip install has no location but a pip install -e (or --editable) has a location, and changing those files adjust what actually runs - which is useful during development, to avoid having to repeatedly reinstall a package after each edit.

@arthurpankiewicz
Copy link
Author

@neiljp I receive the same error when using absolute paths

zulip-run-bot /absolute/path/to/bot --config-file /absolute/path/to/zuliprc

@zulipbot
Copy link
Member

zulipbot commented Aug 16, 2019

Hello @thedeveloperr, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 14 days.

You can reclaim this issue or claim any other issue by commenting @zulipbot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

@aero31aero
Copy link
Member

@arthurpankiewicz I might have some good news on this. We recently merged some code that allows you to import out-of-tree bots in botserver. If you're willing to test this, you would need to install the zulip-botserver package from git; we haven't published a release since this was merged.

zulip/python-zulip-api#523

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants