code: def test_persist_artifacts(storage: StorageContext):
      """Tests typical `StorageContext.persist_artifacts(force=True/False)` usage."""
      trial_local_path = Path(storage.trial_local_path)
      trial_local_path.mkdir(parents=True)
      trial_local_path.joinpath("1.txt").touch()
  
      storage.persist_artifacts()
  
      if not storage.syncer:
          # No syncing is needed -- pass early if storage_path == storage_local_path
          assert _list_at_fs_path(
              storage.storage_filesystem, storage.trial_fs_path
          ) == ["1.txt"]
          return
  
      storage.syncer.wait()
  
      assert sorted(
          _list_at_fs_path(
              storage.storage_filesystem, storage.trial_fs_path
          )
      ) == ["1.txt"]
  
      trial_local_path.joinpath("2.txt").touch()
  
      # A new sync should not be triggered because sync_period is 1000 seconds
      storage.persist_artifacts()
      storage.syncer.wait()
  
      # -> No change in the persisted files
      assert sorted(
          _list_at_fs_path(
              storage.storage_filesystem, storage.trial_fs_path
          )
      ) == ["1.txt"]
  
      # This is what happens on `train.report` when a checkpoint is reported
      # and `sync_artifacts_on_checkpoint=True`
      storage.persist_artifacts(
          force=storage.sync_config.sync_artifacts_on_checkpoint
      )
      assert sorted(
          _list_at_fs_path(
              storage.storage_filesystem, storage.trial_fs_path
          )
      ) == ["1.txt", "2.txt"]
  
file_path: ray/python/ray/train/tests/test_storage.py
imports: import os
  from pathlib import Path
  import pyarrow.fs
  import pytest
  import ray.cloudpickle
  from ray.train import Checkpoint, SyncConfig
  from ray.train._internal.storage import _VALIDATE_STORAGE_MARKER_FILENAME, StorageContext, _list_at_fs_path
  from ray.train.tests.test_new_persistence import _resolve_storage_type
label_desc: Use image node_id 8 for calling a global function with example usage: test_persist_artifacts(storage) without return types