@@ -548,6 +548,50 @@ def get_coefficient_paths(self):
548548 raise ValueError ("This model has no coefficient paths" )
549549 return DSSCoefficientPaths (data )
550550
551+ ## Model export
552+
553+ def get_scoring_jar_stream (self , model_class = "model.Model" , include_libs = False ):
554+ """
555+ Get a scoring jar for this trained model,
556+ provided that you have the license to do so and that the model is compatible with optimized scoring.
557+ You need to close the stream after download. Failure to do so will result in the DSSClient becoming unusable.
558+
559+ :param str model_class: fully-qualified class name, e.g. "com.company.project.Model"
560+ :param bool include_libs: if True, also packs the required dependencies;
561+ if False, runtime will require the scoring libs given by :func:`DSSClient.scoring_libs`
562+ :returns: a jar file, as a stream
563+ :rtype: file-like
564+ """
565+ include_libs = "true" if include_libs else "false"
566+ if self .mltask is not None :
567+ return self .mltask .client ._perform_raw (
568+ "GET" , "/projects/%s/models/lab/%s/%s/models/%s/scoring-jar?fullClassName=%s&includeLibs=%s" %
569+ (self .mltask .project_key , self .mltask .analysis_id , self .mltask .mltask_id , self .mltask_model_id ,
570+ model_class , include_libs ))
571+ else :
572+ return self .saved_model .client ._perform_raw (
573+ "GET" , "/projects/%s/savedmodels/%s/versions/%s/scoring-jar?fullClassName=%s&includeLibs=%s" %
574+ (self .saved_model .project_key , self .saved_model .sm_id , self .saved_model_version ,
575+ model_class , include_libs ))
576+
577+ def get_scoring_pmml_stream (self ):
578+ """
579+ Get a scoring PMML for this trained model,
580+ provided that you have the license to do so and that the model is compatible with PMML scoring
581+ You need to close the stream after download. Failure to do so will result in the DSSClient becoming unusable.
582+
583+ :returns: a PMML file, as a stream
584+ :rtype: file-like
585+ """
586+ if self .mltask is not None :
587+ return self .mltask .client ._perform_raw (
588+ "GET" , "/projects/%s/models/lab/%s/%s/models/%s/scoring-pmml" %
589+ (self .mltask .project_key , self .mltask .analysis_id , self .mltask .mltask_id , self .mltask_model_id ))
590+ else :
591+ return self .saved_model .client ._perform_raw (
592+ "GET" , "/projects/%s/savedmodels/%s/versions/%s/scoring-pmml" %
593+ (self .saved_model .project_key , self .saved_model .sm_id , self .saved_model_version ))
594+
551595
552596class DSSClustersFacts (object ):
553597 def __init__ (self , clusters_facts ):
0 commit comments