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

Delphi train after create model #489

Merged
merged 12 commits into from
Mar 26, 2021
Merged

Conversation

manujinda
Copy link
Collaborator

  1. Train model just after create model
  2. Train and run experiment asynchronously in separate processes. (One problem is that no other process waits for those processes and hence the process IDs associated with each such process ends up allocated till the Flask server is terminated)

Manujinda Wathugala added 12 commits March 13, 2021 15:17
1. Made training occur asynchronously on a separate process.
   Since this process is independent of Flask, it does not have access
   to SQL Alhemy. So, added a new source file, database.cpp, to handle
   database access and added a new method,
   AnalysisGraph::write_model_to_db() to write the trained model back to
   the database.
Earlier test_rest_api.py test script created a temporary database
/tmp/test.db for testing and dropped all the tables t the end of the
test.

Noew it uses the main delphi.db and at the end of the test deletes gthe
test related rows added to the database.

Added some error detection code to the test script.
On 2021/03/15 version1.4 had been released. It creates an error.
pallets-eco/flask-sqlalchemy#885
https://stackoverflow.com/questions/66648383/sqlalchemy-1-4-0-greenlet-greenlet-object-error

2. Add lines to remove test rows added to experimentresults table in
test_rest_api.py

3. Reduced the number of samples burned and retained in
test_cpp_evauation.py
Variable expansion does not seem to work with github yml script.
This is needed to send the sampled beta distributions for each edge to
CauseMos. Thetas are converted to betas before sending by taking
tan(theta).
1. How a new process should be created (spawn, fork etc.) should only be
specified once per script. The way I had included this call makes that
line executed multiple times. Fixed it.

2. Figured out how to pass the Flask app context to a user created
process and updated the code to do so. Now we do not have to rely on C++
to update the database. We can use SQLAlchemy and do it within the user
created process.

3. Made create experiment utilize a user created process to make that
process asynchronous and to quickly send the create model response to
the user.

4. TO TEST THE CREATE MODEL ASYNCHRONOUS BEHAVIOR, ARTIFICIALLY SLOWED
DOWN THE AnalysisGraph::generate_latent_state_sequences() method in
prediction.cpp BY INTRODUCIG A SLEEP(). *** REMOVE THAT BEFORE MERGING
TO MASTER ***.
1. Removed some commented out code

2. Removed unused imports in api.py

3. Removed the artificial slowdown introduced in AnalysisGraph::generate_latent_state_sequences()
@manujinda manujinda merged commit 663797c into master Mar 26, 2021
@manujinda manujinda deleted the delphi_train_after_create_model branch March 26, 2021 16:56
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.

1 participant