def __init__(self, host, prefix, jobdir, max_time=1440, properties=None): try: xenon.init(log_level='INFO') except ValueError: pass # xenon is already initialized self.max_time = max_time urlsplit = self.host.split('://') if len(urlsplit) != 2: raise ValueError("host must contain a scheme and a " "hostname, syntax `scheme://host`.") self.scheme, self.hostname = urlsplit if properties is not None: self.private_key = properties.get('private-key') self.password = properties.get('password') self.xenon_properties = xenon.conversions.dict_to_HashMap({ key[len('xenon-property-'):]: value for key, value in properties.items() if key.startswith('xenon-property-') }) self.scheduler_properties = xenon.conversions.dict_to_HashMap({ key[len('scheduler-property-'):]: value for key, value in properties.items() if key.startswith('scheduler-property-') }) else: self.xenon_properties = None self.scheduler_properties = None self.private_key = None self.password = None
def __init__(self, log_level='ERROR'): if not XenonKeeper.is_initialized: xenon.init(log_level=log_level) # noqa XenonKeeper.is_initialized = True self._x = xenon.Xenon() self.jobs = self._x.jobs() self.credentials = self._x.credentials() self._schedulers = {}
def make_init(): """ Initialize Xenon. After first call, this is a no-op, since jpype cannot be reinitialized. """ # cannot initialize Java classes now with pytest.raises(EnvironmentError): xenon.JavaClass('java.util.Arrays').asList([]) # Override log_level to get more details on the internals, e.g. 'DEBUG' xenon.init() # can initialize Java classes now xenon.JavaClass('java.util.Arrays').asList([])
def xenon_server(request): print("============== Starting Xenon-GRPC server ================") m = xenon.init(do_not_exit=True, disable_tls=False, log_level='INFO') yield m print("============== Closing Xenon-GRPC server =================") for scheduler in xenon.Scheduler.list_schedulers(): jobs = list(scheduler.get_jobs()) statuses = scheduler.get_job_statuses(jobs) for status in statuses: if status.running: print("xenon job {} still running, cancelling ... ".format( status.job.id), end='') try: status = scheduler.cancel_job(status.job) if not status.done: scheduler.wait_until_done(status.job) except xenon.XenonException: print("not Ok") else: print("Ok") m.__exit__(None, None, None)
from xenon import ( PasswordCredential, FileSystem, CopyRequest, Path, CopyStatus, Scheduler, JobDescription) import xenon xenon.init(log_level='INFO') tmpdir = Path('.') location = 'localhost:10022' # # step 0: write our script # sleep_script = [ "#!/bin/bash", "echo \"Sleeping for $1 second(s).\"", "sleep $1" ] with open(str(tmpdir / 'sleep.sh'), 'w') as f: for line in sleep_script: print(line, file=f) # # step 1: upload input files # # create the local filesystem representation local_fs = FileSystem.create(adaptor='file') # the remote system requires credentials, create them here:
A = add(1, 1) B = sub(3, A) multiples = [mul(add(i, B), A) for i in range(6)] C = schedule(sum)(gather_all(multiples)) machine = Machine( scheduler_adaptor='slurm', location='ssh://fs0.das5.cs.vu.nl/home/jhidding', credential=xenon.CertificateCredential( username='******', certfile='/home/johannes/.ssh/id_rsa'), jobs_properties={ 'xenon.adaptors.schedulers.ssh.strictHostKeyChecking': 'false' }) worker_config = XenonJobConfig( prefix=Path('/home/jhidding/.local/share/workon/mcfly'), working_dir='/home/jhidding/', time_out=1000000000000, verbose=False) # , options=['-C', 'TitanX', '--gres=gpu:1']) result = run_xenon(C, machine=machine, worker_config=worker_config, n_processes=2) print("The answer is:", result) xenon.init() test_xenon_42_multi()
def xenon_server(request): print("============== Starting Xenon-GRPC server ================") m = xenon.init(do_not_exit=True, disable_tls=False, log_level='INFO') yield m m.__exit__(None, None, None)