-
Notifications
You must be signed in to change notification settings - Fork 24
ENH Register models trained outside of Civis Platform #242
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,10 @@ | |
| from civis.ml import _model | ||
|
|
||
|
|
||
| LATEST_TRAIN_TEMPLATE = 10582 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand what this change is for. It seems like this is another constant that we'll have to remember to update.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests should fail if we don't update it, which makes it much easier to remember. The problem I had was that we'd used
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the clarification. I think this change is fine; an obvious constant we have to change is better than having to debug a less obvious helper function. |
||
| LATEST_PRED_TEMPLATE = 10583 | ||
|
|
||
|
|
||
| def setup_client_mock(script_id=-10, run_id=100, state='succeeded', | ||
| run_outputs=None): | ||
| """Return a Mock set up for use in testing container scripts | ||
|
|
@@ -682,7 +686,7 @@ def test_modelpipeline_init_newest(): | |
| mp = _model.ModelPipeline(LogisticRegression(), 'test', etl=etl, | ||
| client=mock_client) | ||
| assert mp.etl == etl | ||
| assert mp.train_template_id == max(_model._PRED_TEMPLATES) | ||
| assert mp.train_template_id == LATEST_TRAIN_TEMPLATE | ||
| # clean up | ||
| _model._CIVISML_TEMPLATE = None | ||
|
|
||
|
|
@@ -787,16 +791,15 @@ def test_modelpipeline_classmethod_constructor_defaults( | |
| def test_modelpipeline_classmethod_constructor_future_train_version(): | ||
| # Test handling attempts to restore a model created with a newer | ||
| # version of CivisML. | ||
| current_max_template = max(_model._PRED_TEMPLATES) | ||
| cont = container_response_stub(current_max_template + 1000) | ||
| cont = container_response_stub(LATEST_TRAIN_TEMPLATE + 1000) | ||
| mock_client = mock.Mock() | ||
| mock_client.scripts.get_containers.return_value = cont | ||
| mock_client.credentials.get.return_value = Response({'name': 'Token'}) | ||
|
|
||
| # test everything is working fine | ||
| with pytest.warns(RuntimeWarning): | ||
| mp = _model.ModelPipeline.from_existing(1, 1, client=mock_client) | ||
| exp_p_id = _model._PRED_TEMPLATES[current_max_template] | ||
| exp_p_id = _model._PRED_TEMPLATES[LATEST_TRAIN_TEMPLATE] | ||
| assert mp.predict_template_id == exp_p_id | ||
|
|
||
|
|
||
|
|
@@ -892,7 +895,7 @@ def test_modelpipeline_train_df(mock_ccr, mock_stash, mp_setup): | |
| train_data = pd.DataFrame({'a': [1, 2], 'b': [3, 4]}) | ||
| assert 'res' == mp.train(train_data) | ||
| mock_stash.assert_called_once_with( | ||
| train_data, max(_model._PRED_TEMPLATES.keys()), client=mock.ANY) | ||
| train_data, LATEST_TRAIN_TEMPLATE, client=mock.ANY) | ||
| assert mp.train_result_ == 'res' | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make a ticket as an additional reminder, if you haven't already?