Ejemplo n.º 1
0
def test_submission_time_attr():
    submission_time = datetime.datetime.now()
    ji = JobInfo()
    ji.submission_time = submission_time
    assert (int((ji.submission_time - POSIX_EPOCH).total_seconds()) == int(
        (submission_time - POSIX_EPOCH).total_seconds()))
    print('\nJob info object with submission_time: %s' % (submission_time))
Ejemplo n.º 2
0
def test_dispatch_time_attr():
    dispatch_time = datetime.datetime.now() + datetime.timedelta(hours=1)
    ji = JobInfo()
    ji.dispatch_time = dispatch_time
    assert (int((ji.dispatch_time - POSIX_EPOCH).total_seconds()) == int(
        (dispatch_time - POSIX_EPOCH).total_seconds()))
    print('\nJob info object with dispatch_time: %s' % (dispatch_time))
Ejemplo n.º 3
0
def test_finish_time_attr():
    finish_time = datetime.datetime.now() + datetime.timedelta(hours=24)
    ji = JobInfo()
    ji.finish_time = finish_time
    assert (int((ji.finish_time - POSIX_EPOCH).total_seconds()) == int(
        (finish_time - POSIX_EPOCH).total_seconds()))
    print('\nJob info object with finish_time: %s' % (finish_time))
Ejemplo n.º 4
0
def test_wallclock_time_attr():
    ji = JobInfo()
    wallclock_time = datetime.datetime.fromtimestamp(
        generate_random_int(lower_bound=0, upper_bound=12386400))
    ji.wallclock_time = wallclock_time
    assert (ji.wallclock_time == wallclock_time)
    print('\nJob info with wallclock_time: %s' % (wallclock_time))
Ejemplo n.º 5
0
def test_allocated_machines_attr():
    allocated_machines = []
    n_allocated_machines = generate_random_int(lower_bound=1, upper_bound=5)
    for i in range(0, n_allocated_machines):
        allocated_machines.append(generate_random_string())
    ji = JobInfo()
    ji.allocated_machines = allocated_machines
    assert (ji.allocated_machines == allocated_machines)
    print('\nJob info object with %s allocated_machines: %s' %
          (len(allocated_machines), allocated_machines))
Ejemplo n.º 6
0
def test_implementation_specific_attr():
    implementation_specific = {}
    keys = JobInfo.get_implementation_specific_keys()
    for k in keys:
        v = generate_random_string()
        implementation_specific[k] = v
    ji = JobInfo()
    ji.implementation_specific = implementation_specific
    assert (ji.implementation_specific == implementation_specific)
    print('\nJob info object with implementation_specific: %s' %
          (implementation_specific))
def test_get_all_jobs():
    js = JobSession('js-01')
    j_name = 'drmaa2python-%s' % int(random.uniform(0, 1000))
    j = js.run_job({
        'remote_command': '/bin/sleep',
        'args': ['10'],
        'job_name': j_name
    })
    print('\nSubmitted job: %s' % j)
    ji = j.get_info()
    j.wait_started()
    ms = MonitoringSession('ms-01')
    print('Opened monitoring session: %s' % ms.name)
    ji2 = JobInfo({'job_id': ji.job_id})
    print('Retrieving jobs matching job info %s' % ji2)
    j_list = ms.get_all_jobs(ji2)
    print('Got all jobs: %s' % j_list)
    assert (len(j_list) >= 1)
Ejemplo n.º 8
0
def test_get_jobs():
    js = JobSession('js-01')
    j_name = 'drmaa2python-%s' % int(random.uniform(0, 1000))
    d = {
        'remote_command': '/bin/sleep',
        'args': ['10'],
        'job_name': j_name,
        'output_path': '/dev/null',
        'join_files': True
    }
    j = js.run_job(d)
    print('\nSubmitted job: %s' % j)
    ji = j.get_info()
    print('Retrieving jobs matching job info %s' % ji)
    ji2 = JobInfo({'job_id': ji.job_id})
    j_list = js.get_jobs(ji2)
    print('Got jobs: %s' % j_list)
    assert (len(j_list) >= 1)
Ejemplo n.º 9
0
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###########################################################################
# ___INFO__MARK_END__

import random
from drmaa2 import JobSession
from drmaa2 import JobInfo

if __name__ == '__main__':
    js = JobSession('js-01')
    print('Created job session: %s' % js.name)
    j_name = 'job-%s' % int(random.uniform(0, 1000))
    j = js.run_job({
        'remote_command': '/bin/sleep',
        'args': ['10'],
        'job_name': j_name
    })
    print('Submitted job: %s' % j)
    # ji = j.get_info()
    ji = JobInfo({'job_name': j_name})
    print('Retrieving jobs matching job info %s' % ji)
    j_list = js.get_jobs(ji)
    print('Got jobs: %s' % j_list)
Ejemplo n.º 10
0
def test_job_sub_state_attr():
    ji = JobInfo()
    job_sub_state = generate_random_string()
    ji.job_sub_state = job_sub_state
    assert (ji.job_sub_state == job_sub_state)
    print('\nJob info with job_sub_state: %s' % (job_sub_state))
Ejemplo n.º 11
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################
# ___INFO__MARK_END__

import datetime
from drmaa2 import JobInfo

if __name__ == '__main__':
    import datetime

    print('Impl. spec. keys: %s' % JobInfo.get_implementation_specific_keys())
    ji = JobInfo({'queue_name': 'all.q'})
    print('Initial job info: %s' % ji)
    ji.job_id = '113'
    ji.job_name = 'job-01'
    ji.slots = 10
    ji.job_owner = 'a.user'
    ji.submission_time = datetime.datetime.now()
    ji.cpu_time = 77
    ji.set_impl_spec_key_value('uge_ji_priority', '23')
    print('Impl. spec. key uge_ji_priority is set to: %s' %
          ji.get_impl_spec_key_value('uge_ji_priority'))
    print('Impl. spec dictionary: %s' % ji.implementation_specific)
    print('Final job info: %s' % ji)
Ejemplo n.º 12
0
def test_annotation_attr():
    ji = JobInfo()
    annotation = generate_random_string()
    ji.annotation = annotation
    assert (ji.annotation == annotation)
    print('\nJob info with annotation: %s' % (annotation))
Ejemplo n.º 13
0
def test_job_state_attr():
    ji = JobInfo()
    job_state = JobState(generate_random_int(lower_bound=0, upper_bound=9))
    ji.job_state = job_state
    assert (ji.job_state == job_state.name)
    print('\nJob info with job_state: %s' % (job_state))
Ejemplo n.º 14
0
def test_exit_status_attr():
    ji = JobInfo()
    exit_status = generate_random_int(lower_bound=0, upper_bound=255)
    ji.exit_status = exit_status
    assert (ji.exit_status == exit_status)
    print('\nJob info with exit_status: %s' % (exit_status))
Ejemplo n.º 15
0
def test_terminating_signal_attr():
    ji = JobInfo()
    terminating_signal = generate_random_string()
    ji.terminating_signal = terminating_signal
    assert (ji.terminating_signal == terminating_signal)
    print('\nJob info with terminating_signal: %s' % (terminating_signal))
Ejemplo n.º 16
0
def test_get_implementation_specific_keys():
    keys = JobInfo.get_implementation_specific_keys()
    assert (len(keys) > 0)
    print('\nJob info implementation specific keys: %s' % (keys))
Ejemplo n.º 17
0
def test_job_id_attr():
    ji = JobInfo()
    job_id = generate_random_string()
    ji.job_id = job_id
    assert (ji.job_id == job_id)
    print('\nJob info with job_id: %s' % (job_id))
Ejemplo n.º 18
0
def test_submission_machine_attr():
    ji = JobInfo()
    submission_machine = socket.gethostname()
    ji.submission_machine = submission_machine
    assert (ji.submission_machine == submission_machine)
    print('\nJob info with submission_machine: %s' % (submission_machine))
Ejemplo n.º 19
0
def test_job_owner_attr():
    ji = JobInfo()
    job_owner = generate_random_string()
    ji.job_owner = job_owner
    assert (ji.job_owner == job_owner)
    print('\nJob info with job_owner: %s' % (job_owner))
Ejemplo n.º 20
0
def test_slots_attr():
    ji = JobInfo()
    slots = generate_random_int(lower_bound=0, upper_bound=1024)
    ji.slots = slots
    assert (ji.slots == slots)
    print('\nJob info with slots: %s' % (slots))
Ejemplo n.º 21
0
def test_queue_name_attr():
    ji = JobInfo()
    queue_name = generate_random_string()
    ji.queue_name = queue_name
    assert (ji.queue_name == queue_name)
    print('\nJob info with queue_name: %s' % (queue_name))
Ejemplo n.º 22
0
def test_cpu_time_attr():
    ji = JobInfo()
    cpu_time = generate_random_int(lower_bound=0, upper_bound=86400)
    ji.cpu_time = cpu_time
    assert (ji.cpu_time == cpu_time)
    print('\nJob info with cpu_time: %s' % (cpu_time))