class_docstr: Repacks model artifacts with custom inference entry points.
  
  The SDK automatically adds this step to pipelines that have RegisterModelSteps with models
  that have a custom entry point.
class_docstr_tok: ["Repacks","model","artifacts","with","custom","inference","entry","points",".","The","SDK","automatically","adds","this","step","to","pipelines","that","have","RegisterModelSteps","with","models","that","have","a","custom","entry","point","."]
docstr: Injects the _repack_model.py script and _repack_script_launcher.sh
  
  into S3 or local source directory.
  
  Note: The bash file is needed because if not supplied, the SKLearn
  training job will auto install all dependencies listed in requirements.txt.
  However, this auto install behavior is not expected in _RepackModelStep,
  since it should just simply repack the model along with other supplied files,
  e.g. the requirements.txt.
  
  If the source_dir is an S3 path:
      1) downloads the source_dir tar.gz
      2) extracts it
      3) copies the _repack_model.py script into the extracted directory
      4) creates the _repack_script_launcher.sh in the extracted dir
      5) rezips the directory
      6) overwrites the S3 source_dir with the new tar.gz
  
  If the source_dir is a local path:
      1) copies the _repack_model.py script into the source dir
      2) creates the _repack_script_launcher.sh in the source dir
docstr_tok: ["Injects","the","_repack_model.py","script","and","_repack_script_launcher.sh","into","S3","or","local","source","directory",".","Note",":","The","bash","file","is","needed","because","if","not","supplied",",","the","SKLearn","training","job","will","auto","install","all","dependencies","listed","in","requirements.txt",".","However",",","this","auto","install","behavior","is","not","expected","in","_RepackModelStep",",","since","it","should","just","simply","repack","the","model","along","with","other","supplied","files",",","e.g",".","the","requirements.txt",".","If","the","source_dir","is","an","S3","path",":","1",")","downloads","the","source_dir","tar.gz","2",")","extracts","it","3",")","copies","the","_repack_model.py","script","into","the","extracted","directory","4",")","creates","the","_repack_script_launcher.sh","in","the","extracted","dir","5",")","rezips","the","directory","6",")","overwrites","the","S3","source_dir","with","the","new","tar.gz","If","the","source_dir","is","a","local","path",":","1",")","copies","the","_repack_model.py","script","into","the","source","dir","2",")","creates","the","_repack_script_launcher.sh","in","the","source","dir"]
code: def _inject_repack_script_and_launcher(self):
      """Injects the _repack_model.py script and _repack_script_launcher.sh
  
      into S3 or local source directory.
  
      Note: The bash file is needed because if not supplied, the SKLearn
      training job will auto install all dependencies listed in requirements.txt.
      However, this auto install behavior is not expected in _RepackModelStep,
      since it should just simply repack the model along with other supplied files,
      e.g. the requirements.txt.
  
      If the source_dir is an S3 path:
          1) downloads the source_dir tar.gz
          2) extracts it
          3) copies the _repack_model.py script into the extracted directory
          4) creates the _repack_script_launcher.sh in the extracted dir
          5) rezips the directory
          6) overwrites the S3 source_dir with the new tar.gz
  
      If the source_dir is a local path:
          1) copies the _repack_model.py script into the source dir
          2) creates the _repack_script_launcher.sh in the source dir
      """
      fname = os.path.join(os.path.dirname(__file__), REPACK_SCRIPT)
      if self._source_dir.lower().startswith("s3://"):
          with tempfile.TemporaryDirectory() as tmp:
              targz_contents_dir = os.path.join(tmp, "extracted")
  
              old_targz_path = os.path.join(tmp, "old.tar.gz")
              download_file_from_url(
                  self._source_dir,
                  old_targz_path,
                  self.sagemaker_session,
              )
  
              with tarfile.open(name=old_targz_path, mode="r:gz") as t:
                  t.extractall(path=targz_contents_dir)
  
              shutil.copy2(
                  fname, os.path.join(targz_contents_dir, REPACK_SCRIPT)
              )
              with open(
                  os.path.join(
                      targz_contents_dir, REPACK_SCRIPT_LAUNCHER
                  ),
                  "w",
              ) as launcher_file:
                  launcher_file.write(LAUNCH_REPACK_SCRIPT_CMD)
  
              new_targz_path = os.path.join(tmp, "new.tar.gz")
              with tarfile.open(new_targz_path, mode="w:gz") as t:
                  t.add(targz_contents_dir, arcname=os.path.sep)
  
              _save_model(
                  self._source_dir,
                  new_targz_path,
                  self.sagemaker_session,
                  kms_key=None,
              )
      else:
          shutil.copy2(
              fname, os.path.join(self._source_dir, REPACK_SCRIPT)
          )
          with open(
              os.path.join(self._source_dir, REPACK_SCRIPT_LAUNCHER),
              "w",
          ) as launcher_file:
              launcher_file.write(LAUNCH_REPACK_SCRIPT_CMD)
  
imports: from __future__ import absolute_import
  import logging
  import os
  import shutil
  import tarfile
  import tempfile
  from typing import List, Union, Optional, TYPE_CHECKING
  from sagemaker import image_uris
  from sagemaker.inputs import TrainingInput
  from sagemaker.estimator import EstimatorBase
  from sagemaker.sklearn.estimator import SKLearn
  from sagemaker.workflow.entities import RequestType
  from sagemaker.workflow.properties import Properties
  from sagemaker.session import get_create_model_package_request, get_model_package_args
  from sagemaker.workflow.steps import StepTypeEnum, TrainingStep, Step, ConfigurableRetryStep
  from sagemaker.utils import _save_model, download_file_from_url, format_tags
  from sagemaker.workflow.retry import RetryPolicy
  from sagemaker.workflow.utilities import trim_request_dict
label_desc: Use image node_id 4 for calling the _RepackModelStep obj's underlying member method code with example usage: obj._inject_repack_script_and_launcher() without return types