code: def test_run_from_subds_gh3551(path=None):
      ds = Dataset(path).create(force=True)
      ds.save()
      ds.create("output")
      with chpwd(op.join(ds.path, "sub")):
          assert_in_results(
              run(
                  "echo",
                  inputs=[op.join(op.pardir, "sub", "input")],
                  outputs=[op.join(op.pardir, "output")],
                  return_type="list",
                  result_filter=None,
                  result_xfm=None,
              ),
              action="get",
              status="notneeded",
          )
      assert_repo_status(ds.path)
  
      subds_path = op.join("output", "subds")
      ds.create(subds_path)
      with chpwd(op.join(ds.path, "sub")):
          output_dir = op.join(op.pardir, "output", "subds")
          # The below command is trying to be compatible. It could be made better
          # (e.g., actually using the input file) by someone that knows something
          # about Windows.
          assert_in_results(
              run(
                  "cd .> {}".format(op.join(output_dir, "f")),
                  inputs=[op.join(op.pardir, "sub", "input")],
                  outputs=[output_dir],
                  return_type="list",
                  result_filter=None,
                  result_xfm=None,
              ),
              action="save",
              status="ok",
          )
      assert_repo_status(ds.path)
      subds = Dataset(op.join(ds.path, subds_path))
      ok_exists(op.join(subds.path, "f"))
      if not ds.repo.is_managed_branch():  # FIXME
          # This check fails on Windows:
          # https://github.com/datalad/datalad/pull/3747/checks?check_run_id=248506560#step:8:254
          ok_(subds.repo.file_has_content("f"))
  
imports: import logging
  import os
  import os.path
  import sys
  from os import mkdir, remove
  from unittest.mock import patch
  from datalad.api import clone, run
  from datalad.cli.main import main
  from datalad.core.local.run import _format_iospecs, _get_substitutions, format_command, run_command
  from datalad.distribution.dataset import Dataset
  from datalad.support.exceptions import CommandError, IncompleteResultsError, NoDatasetFound
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, OBSCURE_FILENAME, assert_false, assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, known_failure_windows, neq_, ok_, ok_exists, ok_file_has_content, patch_config, swallow_logs, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import chpwd, ensure_unicode, on_windows
label_desc: Use image node_id 8 for calling a global function with example usage: test_run_from_subds_gh3551(path) without return types