src/sasctl/_services/model_management.py
def publish_model(cls,
                      model,
                      destination,
                      name=None,
                      force=False,
                      reload_model_table=False):
        """

        Parameters
        ----------
        model
        destination
        name
        force : bool, optional
            Whether to overwrite the model if it already exists in the
            publishing `destination`.
        reload_model_table : bool, optional
            Whether the model table in CAS should be reloaded.  Defaults to
            False.

        Returns
        -------

        """
        from .model_repository import ModelRepository
        from .model_publish import ModelPublish

        mr = ModelRepository()
        mp = ModelPublish()

        model_obj = mr.get_model(model)

        if model_obj is None:
            model_name = model.name if hasattr(model, 'name') else str(model)
            raise ValueError("Model '{}' was not found.".format(model_name))

        model_uri = mr.get_model_link(model_obj, 'self')

        # TODO: Verify allowed formats by destination type.
        # As of 19w04 MAS throws HTTP 500 if name is in invalid format.
        model_name = name or '{}_{}'.format(model_obj['name'].replace(' ', ''),
                                            model_obj['id']).replace('-', '')

        request = {
            "name": model_obj.get('name'),
            "notes": model_obj.get('description'),
            "modelContents": [
                {
                    "modelName": mp._publish_name(
                        model_obj.get('name')),
                    "sourceUri": model_uri.get('uri'),
                    "publishLevel": "model"
                }
            ],
            "destinationName": destination
        }

        # Publishes a model that has already been registered in the model
        # repository.
        # Unlike model_publish service, does not require Code to be specified.
        r = cls.post('/publish',
                     json=request,
                     params=dict(force=force,
                                  reloadModelTable=reload_model_table),
                     headers={'Content-Type':
                                   'application/vnd.sas.models.publishing.request.asynchronous+json'})
        return r


        Parameters
        ----------
        model
        destination
        name
        force : bool, optional
            Whether to overwrite the model if it already exists in the
            publishing `destination`.
        reload_model_table : bool, optional
            Whether the model table in CAS should be reloaded.  Defaults to
            False.

        Returns
        -------

        
Parameters
model
destination
name
force : bool, optional
Whether to overwrite the model if it already exists in the
publishing `destination`.
reload_model_table : bool, optional
Whether the model table in CAS should be reloaded.  Defaults to
False.

Returns
Parameters model destination name force : bool optional Whether to overwrite the model if it already exists in the publishing ` destination ` . reload_model_table : bool optional Whether the model table in CAS should be reloaded . Defaults to False . Returns
def publish_model(cls,
                      model,
                      destination,
                      name=None,
                      force=False,
                      reload_model_table=False):
        from .model_repository import ModelRepository
        from .model_publish import ModelPublish
        mr = ModelRepository()
        mp = ModelPublish()
        model_obj = mr.get_model(model)
        if model_obj is None:
            model_name = model.name if hasattr(model, 'name') else str(model)
            raise ValueError("Model '{}' was not found.".format(model_name))
        model_uri = mr.get_model_link(model_obj, 'self')
        model_name = name or '{}_{}'.format(model_obj['name'].replace(' ', ''),
                                            model_obj['id']).replace('-', '')
        request = {
            "name": model_obj.get('name'),
            "notes": model_obj.get('description'),
            "modelContents": [
                {
                    "modelName": mp._publish_name(
                        model_obj.get('name')),
                    "sourceUri": model_uri.get('uri'),
                    "publishLevel": "model"
                }
            ],
            "destinationName": destination
        }
        r = cls.post('/publish',
                     json=request,
                     params=dict(force=force,
                                  reloadModelTable=reload_model_table),
                     headers={'Content-Type':
                                   'application/vnd.sas.models.publishing.request.asynchronous+json'})
        return r
def publish_model ( cls , model , destination , name = None , force = False , reload_model_table = False ) : from . model_repository import ModelRepository from . model_publish import ModelPublish mr = ModelRepository ( ) mp = ModelPublish ( ) model_obj = mr . get_model ( model ) if model_obj is None : model_name = model . name if hasattr ( model , 'name' ) else str ( model ) raise ValueError ( "Model '{}' was not found." . format ( model_name ) ) model_uri = mr . get_model_link ( model_obj , 'self' ) model_name = name or '{}_{}' . format ( model_obj [ 'name' ] . replace ( ' ' , '' ) , model_obj [ 'id' ] ) . replace ( '-' , '' ) request = { "name" : model_obj . get ( 'name' ) , "notes" : model_obj . get ( 'description' ) , "modelContents" : [ { "modelName" : mp . _publish_name ( model_obj . get ( 'name' ) ) , "sourceUri" : model_uri . get ( 'uri' ) , "publishLevel" : "model" } ] , "destinationName" : destination } r = cls . post ( '/publish' , json = request , params = dict ( force = force , reloadModelTable = reload_model_table ) , headers = { 'Content-Type' : 'application/vnd.sas.models.publishing.request.asynchronous+json' } ) return r
Parameters
model
destination
name
force : bool, optional
Whether to overwrite the model if it already exists in the
publishing `destination`.
Parameters model destination name force : bool optional Whether to overwrite the model if it already exists in the publishing ` destination ` .
"""

        Parameters
        ----------
        model
        destination
        name
        force : bool, optional
            Whether to overwrite the model if it already exists in the
            publishing `destination`.
        reload_model_table : bool, optional
            Whether the model table in CAS should be reloaded.  Defaults to
            False.

        Returns
        -------

        """ # TODO: Verify allowed formats by destination type. # As of 19w04 MAS throws HTTP 500 if name is in invalid format. # Publishes a model that has already been registered in the model # repository. # Unlike model_publish service, does not require Code to be specified.
cls
model
destination
name
force
reload_model_table