docstr: save an mlpackage using the save_spec API. It should error out because no weights dir.
docstr_tok: ["save","an","mlpackage","using","the","save_spec","API",".","It","should","error","out","because","no","weights","dir","."]
code: def test_save_spec_api_mlprogram_without_weights_dir(self):
      """
      save an mlpackage using the save_spec API. It should error out because no weights dir.
      """
      spec = self.mlmodel.get_spec()
      with tempfile.TemporaryDirectory(
          suffix=utils._MLPACKAGE_EXTENSION
      ) as model_path:
          # this should raise error:
          with pytest.raises(
              Exception,
              match="spec of type mlProgram cannot be saved without"
              " the weights file. Please provide the path to "
              "the weights file as well, using the 'weights_dir' argument.",
          ):
              utils.save_spec(spec, model_path)
  
imports: import os
  import shutil
  import tempfile
  import numpy
  import pytest
  import coremltools
  from coremltools import ComputeUnit, utils
  from coremltools._deps import _HAS_TORCH
  from coremltools.converters.mil import Builder
  from coremltools.libmodelpackage import ModelPackage
  from coremltools.models import MLModel
  from coremltools.models.utils import _MLPACKAGE_AUTHOR_NAME, _WEIGHTS_DIR_NAME
  from coremltools.proto import Model_pb2
label_desc: Use image node_id 7 for calling the TestSpecAndMLModelAPIs obj's underlying member method code with example usage: obj.test_save_spec_api_mlprogram_without_weights_dir() without return types