def test_publish_sklearn(self): from sasctl.tasks import publish_model from sasctl.services.model_repository import get_model model = get_model(SCIKIT_MODEL_NAME, PROJECT_NAME) p = publish_model(model, 'maslocal', max_retries=100) assert 'score' in p.stepIds
def test_model_publish(self): pytest.xfail( 'Import job pends forever. Waiting on Support Track #7612766673') module = publish_model(self.model_name, 'maslocal', max_retries=60) self.module_name = module.name print('done')
def test_publish_sklearn_again(self): from sasctl.tasks import publish_model from sasctl.services import model_repository as mr model = mr.get_model(SCIKIT_MODEL_NAME, PROJECT_NAME) # Should not be able to republish the model by default with pytest.raises(RuntimeError): publish_model(model, 'maslocal', max_retries=100) # Publish should succeed with replace flag p = publish_model(model, 'maslocal', max_retries=100, replace=True) # Score step should have been defined in the module assert 'score' in p.stepIds # MAS module should automatically have methods bound assert callable(p.score)
def test_publish_sklearn(self): from sasctl.tasks import publish_model from sasctl.services import model_repository as mr model = mr.get_model(SCIKIT_MODEL_NAME, PROJECT_NAME) p = publish_model(model, 'maslocal', max_retries=100) # Score step should have been defined in the module assert 'score' in p.stepIds # MAS module should automatically have methods bound assert callable(p.score)
def test_model_publish(self, request): """Publish the imported model to MAS""" module = publish_model(self.MODEL_NAME, 'maslocal', max_retries=60, replace=True) # SAS module should have a "score" method assert 'score' in module.stepIds # Store module name so we can retrieve it in later tests request.config.cache.set('CAS_MODULE_NAME', module.name)
lr=0.001) # Export the model as an ASTORE and get a reference to the new ASTORE table s.deeplearn.dlexportmodel(modelTable=model.model_table, initWeights=model.model_weights, casout='astore_table') astore = s.CASTable('astore_table') # Connect to the SAS environment with Session('dsasspre', 'robinswu', 'password'): # Register the trained model by providing: # - the ASTORE containing the model # - a name for the model # - a name for the project # # NOTE: the force=True option will create the project if it does not exist. model = register_model(astore, 'Deep Learning', 'PGV', force=True) # Publish the model to SAS® Micro Analytic Service (MAS). Specifically to # the default MAS service "maslocal". module = publish_model(model, 'maslocal') # sasctl wraps the published module with Python methods corresponding to # the various steps defined in the module (like "predict"). response = module.score(SepalLength=5.1, SepalWidth=3.5, PetalLength=1.4, PetalWidth=0.2) s.terminate()
project=project, # Register in "Iris" project force=True) # Create project if it doesn't exist # Update project properties. Target variable must be set before performance # definitions can be created. project = mr.get_project(project) project['targetVariable'] = 'Price' project = mr.update_project(project) # Instruct the project to look for tables in the "Public" CAS library with # names starting with "boston_" and use these tables to track model # performance over time. mm.create_performance_definition(model_name, 'Public', 'boston') # Publish the model to the real-time scoring engine module_lm = publish_model(model_name, 'maslocal') # Select the first row of testing data x = X_test.iloc[0, :] # Call the published module and score the record result = module_lm.score(**x) print(result) # Build a second model dt = DecisionTreeRegressor() dt.fit(X_train, y_train) # Register the second model in Model Manager model_dt = register_model(dt, 'Decision Tree', project, input=X)