Getting Started
Access client package provides connect() function to connect to
Access Web server and returns AccessClient
object. Using submit_job() method of AccessClient,
a job can be submitted and returned Job object can be used to
perform operations on that job.
An example of the client
code:
import access.client as access_client
with access_client.connect("https://23centos7:4443", "david") as client:
job_input = {"CORES":"1","MEMORY":"1","EXECUTION_PLATFORM":"linux","PRIMARY_FILE":"/stage/david/generate_data.py", "FILES":"","CHUNKS":"1","CHUNK_PLACEMENT":"pack","MEMORY_PLACEMENT":"true","JOB_NAME":"Generate Data","SUBMISSION_DIRECTORY":"/stage/david/generate_data"}
# NOTE: User has to provide password in the prompt
# Enter password for user 'david': ········
job_obj = client.submit_job("ShellScript", job_input)
print(job_obj)
# Get current job status
job_status = job_obj.status()
# Wait till job is finished
job_obj.wait()
# Download any job file
data_file_path = job_obj.download_file("data.csv")
print(open(data_file_path).read())
# Remove job from WLM
job_obj.delete()
# Delete all job files downloaded using 'download_file' API
job_obj.clean()Methods chaining is supported on job
object:
import access.client as access_client
client = access_client.connect("https://23centos7:4443", "david")
# NOTE: User has to provide password in the prompt
# Enter password for user 'david': ········
data_file_path = client.submit_job("ShellScript", job_input) \
.wait() \
.download_file("data.csv")
print(open(data_file_path).read())
# Close client explicitly as it is not opened using 'with' statement
client.close()