PySlurm / pyslurm

Python Interface to Slurm
https://pyslurm.github.io
GNU General Public License v2.0
467 stars 116 forks source link

Missing `Job` fields compared to the docs #299

Closed multimeric closed 1 year ago

multimeric commented 1 year ago

Details

Issue

The following fields are listed as attributes of a Job object in the documentation but aren't present on a Job I get from Job.load or Jobs.load:

``` sockets_per_board last_sched_evaluation_time deadline boards_per_node memory_per_cpu cores_per_socket spreads_over_nodes federation_siblings_viable preempt_time scheduled_nodes federation_siblings_active heterogeneous_offset cluster_constraints sockets_per_node preempt_eligible_time standard_error requeue_count licenses resize_time power_options gres_per_node threads_per_core cpu_frequency_max allocated_nodes heterogeneous_id requires_contiguous_nodes ntasks_per_board standard_output cpus_per_gpu excluded_nodes batch_host cpu_time time_limit_min accrue_time cpus_per_task command is_cronjob ntasks submit_host dependencies cores_reserved_for_system nice run_time network federation_origin burst_buffer_state cpu_frequency_min threads_reserved_for_system batch_constraints required_switches required_nodes mail_types max_nodes kill_on_invalid_dependency ntasks_per_socket min_cpus_per_node temporary_disk_per_node cronjob_time memory_per_node max_wait_time_switches standard_input ntasks_per_core mail_user delay_boot_time suspend_time memory_per_gpu cpu_frequency_governor ntasks_per_gpu pre_suspension_time profile_types burst_buffer node_reboot_required is_batch_job gres_binding is_requeueable ntasks_per_node resource_sharing ```

For example:

>>> x
<pyslurm.db.job.Job object at 0x7f0f510c7010>
>>> x.ntasks_per_node
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'pyslurm.db.job.Job' object has no attribute 'ntasks_per_node'
>>> x.mail_user
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'pyslurm.db.job.Job' object has no attribute 'mail_user'
tazend commented 1 year ago

Hi,

you have a pyslurm.db.Job instance, i.e. an object that represents a database Job, which does not have these attributes. The attributes you want are only available on a pyslurm.Job instance, i.e. jobs that are still present in slurmctlds memory

If you do:

job = pyslurm.Job.load(<job_id>)

it should work.

multimeric commented 1 year ago

Ah, many thanks. I've made this mistake several times which is largely my fault but I guess it poses the question about whether the actual class names should be slightly different from each other.