code: def _test_remote_layout(host, dspath, store, archiv_store):
      dspath = Path(dspath)
      store = Path(store)
      archiv_store = Path(archiv_store)
      ds = Dataset(dspath).create()
      populate_dataset(ds)
      assert_repo_status(ds.path)
  
      # set up store:
      io = SSHRemoteIO(host) if host else LocalIO()
      if host:
          store_url = "ria+ssh://{host}{path}".format(
              host=host, path=store
          )
          arch_url = "ria+ssh://{host}{path}".format(
              host=host, path=archiv_store
          )
      else:
          store_url = "ria+{}".format(store.as_uri())
          arch_url = "ria+{}".format(archiv_store.as_uri())
  
      create_store(io, store, "1")
  
      # TODO: Re-establish test for version 1
      # version 2: dirhash
      create_ds_in_store(io, store, ds.id, "2", "1")
  
      # add special remote
      init_opts = common_init_opts + ["url={}".format(store_url)]
      ds.repo.init_remote("store", options=init_opts)
  
      # copy files into the RIA store
      ds.push(".", to="store")
  
      # we should see the exact same annex object tree
      dsgit_dir, archive_dir, dsobj_dir = get_layout_locations(
          1, store, ds.id
      )
      store_objects = get_all_files(dsobj_dir)
      local_objects = get_all_files(
          ds.pathobj / ".git" / "annex" / "objects"
      )
      assert_equal(len(store_objects), 4)
  
      if not ds.repo.is_managed_branch():
          # with managed branches the local repo uses hashdirlower instead
          # TODO: However, with dataset layout version 1 this should therefore
          #       work on adjusted branch the same way
          # TODO: Wonder whether export-archive-ora should account for that and
          #       rehash according to target layout.
          assert_equal(
              sorted([p for p in store_objects]),
              sorted([p for p in local_objects]),
          )
  
          if not io.get_7z():
              raise SkipTest("No 7z available in RIA store")
  
          # we can simply pack up the content of the remote into a
          # 7z archive and place it in the right location to get a functional
          # archive remote
  
          create_store(io, archiv_store, "1")
          create_ds_in_store(io, archiv_store, ds.id, "2", "1")
  
          whereis = ds.repo.whereis("one.txt")
          dsgit_dir, archive_dir, dsobj_dir = get_layout_locations(
              1, archiv_store, ds.id
          )
          ds.export_archive_ora(archive_dir / "archive.7z")
          init_opts = common_init_opts + ["url={}".format(arch_url)]
          ds.repo.init_remote("archive", options=init_opts)
          # now fsck the new remote to get the new special remote indexed
          ds.repo.fsck(remote="archive", fast=True)
          assert_equal(
              len(ds.repo.whereis("one.txt")), len(whereis) + 1
          )
          # test creating an archive with filters on files
          ds.export_archive_ora(
              archive_dir / "archive2.7z",
              annex_wanted="(include=*.txt)",
          )
          # test with wanted expression of a specific remote
          ds.repo.set_preferred_content(
              "wanted", "include=subdir/*", remote="store"
          )
          ds.export_archive_ora(
              archive_dir / "archive3.7z", remote="store"
          )
          # test with the current sha
          ds.export_archive_ora(
              archive_dir / "archive4.7z",
              froms=ds.repo.get_revisions()[1],
          )
  
imports: import logging
  import stat
  from datalad.api import Dataset, clone, create_sibling_ria
  from datalad.cmd import NoCapture
  from datalad.customremotes.ria_utils import create_ds_in_store, create_store, get_layout_locations
  from datalad.distributed.ora_remote import LocalIO, SSHRemoteIO, _sanitize_key
  from datalad.distributed.tests.ria_utils import common_init_opts, get_all_files, populate_dataset
  from datalad.support.exceptions import CommandError, IncompleteResultsError
  from datalad.tests.utils_pytest import SkipTest, assert_equal, assert_false, assert_in, assert_not_in, assert_raises, assert_repo_status, assert_status, assert_true, has_symlink_capability, known_failure_windows, serve_path_via_http, skip_if_adjusted_branch, skip_if_no_network, skip_if_root, skip_ssh, skip_wo_symlink_capability, slow, swallow_logs, turtle, with_tempfile
  from datalad.utils import Path
label_desc: Use image node_id 10 for calling a global function with example usage: _test_remote_layout(host, dspath, store, archiv_store) without return types