def cancel(): """ Main cancel function. Gets the cancel command from the environment variable (defined in supercomputer cfgs) and includes the job identifiers to be cancelled. :return: None """ if VERBOSE: print("Cancelling PyCOMPSs interactive job...") # Get command line arguments job_ids = sys.argv[1:] # Load the Supercomputer configuration to get the appropriate cancel command setup_supercomputer_configuration() success = True # There might be more than one to cancel for job_id in job_ids: if VERBOSE: print(" - Job: " + str(job_id)) # Check if the job_id belongs to a notebook before continuing if not is_notebook_job(job_id): not_a_notebook(job_id) # Get the command to cancel the job raw_cancel_command = os.environ['QUEUE_JOB_CANCEL_CMD'] cancel_command = update_command(raw_cancel_command, job_id) # Cancel the job return_code, _, _ = command_runner(cancel_command) if return_code != 0: success = False if VERBOSE: print("Finished cancellation.") # Print to notify the cancel result if success: print(SUCCESS_KEYWORD) else: print(ERROR_KEYWORD) exit(1)
def status(): """ Main status function. Gets the status of the requested job identifier and prints it through stdout. :return: None """ if VERBOSE: print("Checking status PyCOMPSs interactive job...") # Get command line arguments job_id = sys.argv[1] if VERBOSE: print(" - Job: " + str(job_id)) # Load the Supercomputer configuration to get the appropriate status command setup_supercomputer_configuration() # Check if the job_id belongs to a notebook before continuing if not is_notebook_job(job_id): not_a_notebook(job_id) # Get the job status job_status, return_code = get_job_status(job_id) if VERBOSE: print("Finished checking status.") # Print to notify the status result if return_code != 0: print(ERROR_KEYWORD) exit(1) else: print(SUCCESS_KEYWORD) print("STATUS:" + job_status)
def info(): """ Main info function. Gets the information command from the jupyter server (master node and url) and prints it through stdout. So that the client can get it, parse and connect to the running notebook. :return: None """ if VERBOSE: print("Checking information of PyCOMPSs interactive job...") # Get command line arguments job_id = sys.argv[1] if VERBOSE: print(" - Job: " + str(job_id)) # Load the Supercomputer configuration to get the appropriate status command setup_supercomputer_configuration() # Check if the job_id belongs to a notebook before continuing if not is_notebook_job(job_id): not_a_notebook(job_id) # Get the list of nodes raw_nodes_command = os.environ['QUEUE_JOB_NODES_CMD'] nodes_command = update_command(raw_nodes_command, job_id) return_code, nodes, _ = command_runner(nodes_command) if return_code != 0: print(ERROR_KEYWORD) exit(1) # Look for the master node if nodes.strip(): nodes_expansor = os.environ['HOSTLIST_CMD'] + ' ' + nodes _, expanded_nodes, _ = command_runner(nodes_expansor.split()) expanded_nodes = expanded_nodes.splitlines() master = expanded_nodes[0] if VERBOSE: print(" - Nodes: " + str(expanded_nodes)) print(" - Found master: " + str(master)) # Get the command to contact with the node where the job is running server_list = os.environ[ 'CONTACT_CMD'] + ' ' + master + " jupyter-notebook list" return_code, jupyter_server_list, _ = command_runner( server_list.split()) if VERBOSE: print("Finished checking the information.") # Print to notify the info result if return_code != 0: print(ERROR_KEYWORD) exit(1) else: print(SUCCESS_KEYWORD) print("MASTER:" + str(master)) print("SERVER: " + str(jupyter_server_list.replace('\n', ' '))) else: # Print to provide information to the client print(NOT_RUNNING_KEYWORD) # The notebook is not ready yet exit(1)