code: def copyDirectoryToHdfs(localDirectory, hdfsDirectory, hdfsClient):
      """Copy directory from local to HDFS"""
      if not os.path.exists(localDirectory):
          raise Exception("Local Directory does not exist!")
      hdfsClient.mkdirs(hdfsDirectory)
      result = True
      for file in os.listdir(localDirectory):
          file_path = os.path.join(localDirectory, file)
          if os.path.isdir(file_path):
              hdfs_directory = os.path.join(hdfsDirectory, file)
              try:
                  result = result and copyDirectoryToHdfs(
                      file_path, hdfs_directory, hdfsClient
                  )
              except Exception as exception:
                  nni_log(
                      LogType.Error,
                      "Copy local directory {0} to hdfs directory {1} error: {2}".format(
                          file_path, hdfs_directory, str(exception)
                      ),
                  )
                  result = False
          else:
              hdfs_file_path = os.path.join(hdfsDirectory, file)
              try:
                  result = result and copyFileToHdfs(
                      file_path, hdfs_file_path, hdfsClient
                  )
              except Exception as exception:
                  nni_log(
                      LogType.Error,
                      "Copy local file {0} to hdfs {1} error: {2}".format(
                          file_path, hdfs_file_path, str(exception)
                      ),
                  )
                  result = False
      return result
  
imports: import os
  import posixpath
  from .log_utils import LogType, nni_log
label_desc: Use image node_id 3 for calling a global function with example usage: copyDirectoryToHdfs(localDirectory, hdfsDirectory, hdfsClient) and returns: result