class_docstr: Base class for the job.
  
  After establishing connection with the remote object, the job will
  create a remote class instance locally and enter an infinite loop
  in a separate process, waiting for commands from the remote object.
class_docstr_tok: ["Base","class","for","the","job",".","After","establishing","connection","with","the","remote","object",",","the","job","will","create","a","remote","class","instance","locally","and","enter","an","infinite","loop","in","a","separate","process",",","waiting","for","commands","from","the","remote","object","."]
docstr: Wait for python files from remote object.
  
  When a remote object receives the allocated job address, it will send
  the python files to the job. Later, the job will save these files to a
  temporary directory and add the temporary diretory to Python's working
  directory.
  
  Args:
      reply_socket (sockert): main socket to accept commands of remote object.
      job_address (String): address of reply_socket.
  
  Returns:
      A temporary directory containing the python files.
docstr_tok: ["Wait","for","python","files","from","remote","object",".","When","a","remote","object","receives","the","allocated","job","address",",","it","will","send","the","python","files","to","the","job",".","Later",",","the","job","will","save","these","files","to","a","temporary","directory","and","add","the","temporary","diretory","to","Python","'s","working","directory",".","Args",":","reply_socket","(","sockert",")",":","main","socket","to","accept","commands","of","remote","object",".","job_address","(","String",")",":","address","of","reply_socket",".","Returns",":","A","temporary","directory","containing","the","python","files","."]
code: def wait_for_files(self, reply_socket, job_address):
      """Wait for python files from remote object.
  
      When a remote object receives the allocated job address, it will send
      the python files to the job. Later, the job will save these files to a
      temporary directory and add the temporary diretory to Python's working
      directory.
  
      Args:
          reply_socket (sockert): main socket to accept commands of remote object.
          job_address (String): address of reply_socket.
  
      Returns:
          A temporary directory containing the python files.
      """
  
      message = reply_socket.recv_multipart()
      tag = message[0]
      if tag == remote_constants.SEND_FILE_TAG:
          pyfiles = pickle.loads(message[1])
          envdir = tempfile.mkdtemp()
  
          for empty_subfolder in pyfiles["empty_subfolders"]:
              empty_subfolder_path = os.path.join(
                  envdir, empty_subfolder
              )
              if not os.path.exists(empty_subfolder_path):
                  os.makedirs(empty_subfolder_path)
  
          # save python files to temporary directory
          for file, code in pyfiles["python_files"].items():
              file = os.path.join(envdir, file)
              with open(file, "wb") as code_file:
                  code_file.write(code)
  
          # save other files to current directory
          for file, content in pyfiles["other_files"].items():
              # create directory (i.e. ./rom_files/)
              if os.sep in file:
                  try:
                      sep = os.sep
                      recursive_dirs = os.path.join(
                          *(file.split(sep)[:-1])
                      )
                      recursive_dirs = os.path.join(
                          envdir, recursive_dirs
                      )
                      os.makedirs(recursive_dirs)
                  except OSError as e:
                      pass
              file = os.path.join(envdir, file)
              with open(file, "wb") as f:
                  f.write(content)
          reply_socket.send_multipart([remote_constants.NORMAL_TAG])
          return envdir
      else:
          logger.error(
              "NotImplementedError:{}, received tag:{}".format(
                  job_address, tag
              )
          )
          raise NotImplementedError
  
imports: import os
  import compatible_trick
  import argparse
  import cloudpickle
  import pickle
  import psutil
  import re
  import sys
  import tempfile
  import shutil
  import threading
  import time
  import traceback
  import zmq
  import importlib
  import parl
  from multiprocessing import Process, Pipe
  from parl.utils import to_str, to_byte, get_ip_address, logger
  from parl.remote.communication import loads_argument, loads_return, dumps_argument, dumps_return
  from parl.remote import remote_constants
  from parl.utils.exceptions import SerializeError, DeserializeError
  from parl.remote.message import InitializedJob
  from parl.remote.utils import redirect_output_to_file
  from parl.remote.remote_class_serialization import load_remote_class
  from parl.remote.zmq_utils import create_server_socket, create_client_socket
  from parl.remote.grpc_heartbeat import HeartbeatServerThread, HeartbeatClientThread
label_desc: Use image node_id 5 for calling the Job obj's underlying member method code with example usage: obj.wait_for_files(reply_socket, job_address) and returns: envdir