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

Feature proposal: a honcho module API #208

Open
christophevg opened this issue Oct 20, 2018 · 3 comments
Open

Feature proposal: a honcho module API #208

christophevg opened this issue Oct 20, 2018 · 3 comments

Comments

@christophevg
Copy link

Hi,

I'm currently working on a small wrapper project around honcho. I want to add some application control (e.g. scheduling, respawning,...) around the honcho Procfile starting capability. To do so I want to use honcho from some other Python script.

At this point, honcho is primarily focussed on being run as a command line utility and not so much on being called from other Python code. For example, if I want to start an application with a Procfile, I have to mimic the CLI approach like this:

from honcho.command import command_start, parser
def main():
  args = parser.parse_args(["start"])
  command_start(args)

Doable, but a main drawback is that I have little control with respect to the outcome. I think a honcho module API would be a nice addition to the project. With such an API, the code above could look something like:

import honcho
def main():
  result = honcho.start()

Since I'm about to write such a layer in my project, duplicating a lot of code from inside the honcho module, I could also apply this directly to the honcho module and submit it as a PR. But since this is of course a "larger" PR, possibly with more consequences, I prefer to first propose it and discuss any feelings about it.

regards,
Christophe

@christophevg
Copy link
Author

As I ran into more issues than first expected, simply creating a wrapper in my project didn't cut it anymore ;-) To be able to continue, I forked Honcho to my own space and started working on separating the command-line interface from the actual Honcho Python code, to see where I could go with this.

A very rough cut currently does the trick (and even passes the tests ;-)), but will need some more love. So far it looks like this:

The command-line related stuff still resides in:
https://github.com/christophevg/honcho/blob/api/honcho/command.py

But the Honcho class (aka API) now lives in:
https://github.com/christophevg/honcho/blob/api/honcho/init.py

And this basically allows one to write:

from honcho import Honcho
honcho = Honcho()
honcho.start()

Still, although most of the code now already has been written, it is still more of an open invitation to discuss this, and if it seems a valid feature, I'm more than willing to go through the code in detail to bring everything up to par of the rest of the codebase and in line with the projects preferred style, etc.

regards,
Christophe

@christophevg
Copy link
Author

Whoops, wrong button :-(

@christophevg christophevg reopened this Oct 21, 2018
@nickstenning
Copy link
Owner

It seems to me that the proposal here is actually to introduce a higher-level API to Honcho that mostly emulates the CLI, as you can already use honcho.manager.Manager directly from within Python and I know that quite a few folks do that.

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

No branches or pull requests

2 participants