code: def put_local_file_to_remote(
      local_path: str, remote_path: str, filemode: Optional[int] = None
  ) -> int:
      if remote_path.startswith("hdfs"):  # hdfs://url:port/file_path
          cmd = "hdfs dfs -put -f {} {}".format(local_path, remote_path)
          p = subprocess.run(cmd, capture_output=True)
          if p.returncode != 0:
              logger.error(
                  "Cannot upload file {} to {}: error: {}".format(
                      local_path, remote_path, str(p.stderr)
                  )
              )
              return -1
          if filemode:
              chmod_cmd = "hdfs dfs -chmod {} {}".format(
                  filemode, remote_path
              )
              p = subprocess.run(chmod_cmd, capture_output=True)
              if p.returncode != 0:
                  logger.error(
                      "Cannot upload file {} to {}: error: {}".format(
                          local_path, remote_path, str(p.stderr)
                      )
                  )
                  return -1
          return 0
      elif remote_path.startswith("s3"):  # s3://bucket/file_path
          access_key_id = os.environ["AWS_ACCESS_KEY_ID"]
          secret_access_key = os.environ["AWS_SECRET_ACCESS_KEY"]
          import boto3
  
          try:
              s3_client = boto3.Session(
                  aws_access_key_id=access_key_id,
                  aws_secret_access_key=secret_access_key,
              ).client("s3")
              path_parts = remote_path.split("://")[1].split("/")
              bucket = path_parts.pop(0)
              prefix = "/".join(path_parts)
              with open(local_path, "rb") as f:
                  s3_client.upload_fileobj(f, Bucket=bucket, Key=prefix)
          except Exception as e:
              logger.error(
                  "Cannot upload file {} to {}: error: {}".format(
                      local_path, remote_path, str(e)
                  )
              )
              return -1
          return 0
      else:
          if remote_path.startswith("file://"):
              remote_path = remote_path[len("file://") :]
          try:
              shutil.copy(local_path, remote_path)
              if filemode:
                  os.chmod(remote_path, filemode)
          except Exception as e:
              logger.error(
                  "Cannot upload file {} to {}: error: {}".format(
                      local_path, remote_path, str(e)
                  )
              )
              return -1
          return 0
  
imports: import os
  import subprocess
  import logging
  import shutil
  import functools
  import glob
  from distutils.dir_util import copy_tree
  from bigdl.dllib.utils.log4Error import invalidOperationError
  from typing import TYPE_CHECKING, List, Callable, Union, Optional
label_desc: Use image node_id 12 for calling a global function with example usage: put_local_file_to_remote(local_path, remote_path, filemode) and returns: int, unknown, int, int, unknown, unknown, unknown