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

Flask to klein no agents #450

Merged
merged 60 commits into from
Jul 26, 2017
Merged

Flask to klein no agents #450

merged 60 commits into from
Jul 26, 2017

Conversation

PHLF
Copy link
Contributor

@PHLF PHLF commented Jun 28, 2017

Proposed changes:

Status:

  • ready for code review
  • there are tests for the functionality
  • documentation updated
  • changelog updated

Issues introduced by this change:

Original PR: #426

PHLF added 30 commits May 29, 2017 04:08
This is necessary to be able to circumvent joblib issue 180  joblib/joblib#180

- Moved the pool of workers from the server into the datarouter
- Make use of concurrent.future ProcessPoolExecutor
- May have broken an insane amount of code
- Need to figure out how to pickle the result's objects from the workers processes
Conflicts:
	rasa_nlu/model.py
- Fixed `parse()` method moved out of model class
- Reintroduced a thread pool at the server level to handle parse requests
Conflicts:
	rasa_nlu/components.py
@PHLF
Copy link
Contributor Author

PHLF commented Jul 19, 2017

As multiprocessing introduced a lot of hacky code, I gave another try at pytest-twisted and treq. It appears that I had some issue with a deferToThread call as there is no threadpool in the StubTreq in memory reactor. Looks way cleaner now.

__version__ = None # Avoids IDE errors, but actual version is read from version.py
exec(open('rasa_nlu/version.py').read())
__version__ = None # Avoids IDE errors, but actual version is read from version.py
exec (open('rasa_nlu/version.py').read())

tests_requires = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be edited, doesn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All packages listed in requirements.txt and dev-requirements.txt should also be listed here, shouldn't they?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so all requirements in requirements.txt should show up here, yes. dev_requirements.txt are optional

self.config = config
self.responses = DataRouter._create_query_logger(config['response_log'])
self._train_procs = []
self._trainings_queued = 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the low-level training process tracking was replaced by this simple counter. But, in my opinion, as the processes are now managed by the ProcessPool object, they are too low-level to be accessed and managed directly. This situation could be improved a lot by finishing the transition to a higher-level endpoints tracking (see my other PR).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@app.route("/train", methods=['POST'])
@requires_auth
def train(self, request):
def errback(f):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we could take advantage of the server's async nature by only answering the client once the training is done or failed (the server can still handle other clients requests).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds great, let's do that 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but make sure to mention that in the changelog and the migration file (as anyone calling that api will now need to wait till it is finished training)

@tmbo
Copy link
Member

tmbo commented Jul 21, 2017

Coverage looks good, nice 👍

I think we are very close, exiting 🎉 Final steps:

  • add to changelog
  • address two comments (naming of deferred_from_future and your comment in setup.py)
  • merge master and add CORS support (hopefully that is as simple as it was for flask)

Is there anything that needs to be addressed in the documentation? I don't think so, right?

@PHLF
Copy link
Contributor Author

PHLF commented Jul 21, 2017

As for the doc, one cannot longer make use of gunicorn + wsgi as the asynchronous processing is not part of the WSGI spec.
What should be changed regarding: deferred_from_future?
For CORS support, I'll simply try to add the corresponding header to the response if the option is set in the config.

@tmbo
Copy link
Member

tmbo commented Jul 21, 2017

ok let's remove gunicorn + wsgi then. Nevermind, deferred_from_future all good there. CORS header sounds good 👍

PHLF added 6 commits July 21, 2017 20:38
- A request to the `/train` endpoint will now wait for the server answer
- CORS checking has now its own decorator
- Introduced another codepath for testing the training
- Some minor test fixes
@PHLF
Copy link
Contributor Author

PHLF commented Jul 22, 2017

I think it's ready for merge.

@tmbo tmbo merged commit c660ac1 into RasaHQ:master Jul 26, 2017
@tmbo
Copy link
Member

tmbo commented Jul 26, 2017

🎉 great work 👍

@PHLF
Copy link
Contributor Author

PHLF commented Jul 26, 2017

Thanks. Let's see how many new issues will be created following 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

Successfully merging this pull request may close these issues.

None yet

2 participants