code: def test_retrieve_artifacts(LocalSession, tmpdir):
      sagemaker_container = _SageMakerContainer("local", 2, "my-image")
      sagemaker_container.hosts = [
          "algo-1",
          "algo-2",
      ]  # avoid any randomness
      sagemaker_container.container_root = str(
          tmpdir.mkdir("container-root")
      )
  
      volume1 = os.path.join(
          sagemaker_container.container_root, "algo-1"
      )
      volume2 = os.path.join(
          sagemaker_container.container_root, "algo-2"
      )
      os.mkdir(volume1)
      os.mkdir(volume2)
  
      compose_data = {
          "services": {
              "algo-1": {
                  "volumes": [
                      "%s:/opt/ml/model"
                      % os.path.join(volume1, "model"),
                      "%s:/opt/ml/output"
                      % os.path.join(volume1, "output"),
                  ]
              },
              "algo-2": {
                  "volumes": [
                      "%s:/opt/ml/model"
                      % os.path.join(volume2, "model"),
                      "%s:/opt/ml/output"
                      % os.path.join(volume2, "output"),
                  ]
              },
          }
      }
  
      dirs = [
          ("model", volume1),
          ("model/data", volume1),
          ("model", volume2),
          ("model/data", volume2),
          ("model/tmp", volume2),
          ("output", volume1),
          ("output/data", volume1),
          ("output", volume2),
          ("output/data", volume2),
          ("output/log", volume2),
      ]
  
      files = [
          ("model/data/model.json", volume1),
          ("model/data/variables.csv", volume1),
          ("model/data/model.json", volume2),
          ("model/data/variables2.csv", volume2),
          ("model/tmp/something-else.json", volume2),
          ("output/data/loss.json", volume1),
          ("output/data/accuracy.json", volume1),
          ("output/data/loss.json", volume2),
          ("output/data/accuracy2.json", volume2),
          ("output/log/warnings.txt", volume2),
      ]
  
      expected_model = [
          "data",
          "data/model.json",
          "data/variables.csv",
          "data/variables2.csv",
          "tmp/something-else.json",
      ]
      expected_output = [
          "data",
          "log",
          "data/loss.json",
          "data/accuracy.json",
          "data/accuracy2.json",
          "log/warnings.txt",
      ]
  
      for d, volume in dirs:
          os.mkdir(os.path.join(volume, d))
  
      # create all the files
      for f, volume in files:
          open(os.path.join(volume, f), "a").close()
  
      output_path = str(tmpdir.mkdir("exported_files"))
      output_data_config = {"S3OutputPath": "file://%s" % output_path}
  
      model_artifacts = sagemaker_container.retrieve_artifacts(
          compose_data, output_data_config, sagemaker_session
      ).replace("file://", "")
      artifacts = os.path.dirname(model_artifacts)
  
      # we have both the tar files
      assert set(os.listdir(artifacts)) == {
          "model.tar.gz",
          "output.tar.gz",
      }
  
      # check that the tar files contain what we expect
      tar = tarfile.open(os.path.join(output_path, "model.tar.gz"))
      model_tar_files = [m.name for m in tar.getmembers()]
      for f in expected_model:
          assert f in model_tar_files
  
      tar = tarfile.open(os.path.join(output_path, "output.tar.gz"))
      output_tar_files = [m.name for m in tar.getmembers()]
      for f in expected_output:
          assert f in output_tar_files
      tar.close()
  
imports: from __future__ import absolute_import
  import random
  import string
  from botocore.credentials import Credentials
  import base64
  import logging
  import json
  import os
  import subprocess
  import tarfile
  import pytest
  import yaml
  from mock import patch, Mock, MagicMock, mock_open, call
  import sagemaker
  from sagemaker.local.image import _SageMakerContainer, _Volume, _aws_credentials
  from sagemaker.local.utils import STUDIO_APP_TYPES
label_desc: Use image node_id 9 for calling a global function with example usage: test_retrieve_artifacts(LocalSession, tmpdir) without return types