@@ -47,15 +47,12 @@ class JobStatus:
4747 stage : JobStage
4848 message : Optional [str ]
4949
50- def __init__ (self , ** kwargs ) -> None :
51- self .stage = kwargs ["stage" ]
52- self .message = kwargs .get ("message" )
53-
5450
5551@dataclass
5652class JobOwner :
5753 id : str
5854 name : str
55+ type : str
5956
6057
6158@dataclass
@@ -89,7 +86,7 @@ class JobInfo:
8986 Status of the Job, e.g. `JobStatus(stage="RUNNING", message=None)`
9087 See [`JobStage`] for possible stage values.
9188 status: (`JobOwner` or `None`):
92- Owner of the Job, e.g. `JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq")`
89+ Owner of the Job, e.g. `JobOwner(id="5e9ecfc04957053f60648a3e", name="lhoestq", type="user" )`
9390
9491 Example:
9592
@@ -100,7 +97,7 @@ class JobInfo:
10097 ... command=["python", "-c", "print('Hello from the cloud!')"]
10198 ... )
10299 >>> job
103- JobInfo(id='687fb701029421ae5549d998', created_at=datetime.datetime(2025, 7, 22, 16, 6, 25, 79000, tzinfo=datetime.timezone.utc), docker_image='python:3.12', space_id=None, command=['python', '-c', "print('Hello from the cloud!')"], arguments=[], environment={}, secrets={}, flavor='cpu-basic', status=JobStatus(stage='RUNNING', message=None), owner=JobOwner(id='5e9ecfc04957053f60648a3e', name='lhoestq'), endpoint='https://huggingface.co', url='https://huggingface.co/jobs/lhoestq/687fb701029421ae5549d998')
100+ JobInfo(id='687fb701029421ae5549d998', created_at=datetime.datetime(2025, 7, 22, 16, 6, 25, 79000, tzinfo=datetime.timezone.utc), docker_image='python:3.12', space_id=None, command=['python', '-c', "print('Hello from the cloud!')"], arguments=[], environment={}, secrets={}, flavor='cpu-basic', status=JobStatus(stage='RUNNING', message=None), owner=JobOwner(id='5e9ecfc04957053f60648a3e', name='lhoestq', type='user' ), endpoint='https://huggingface.co', url='https://huggingface.co/jobs/lhoestq/687fb701029421ae5549d998')
104101 >>> job.id
105102 '687fb701029421ae5549d998'
106103 >>> job.url
@@ -119,8 +116,8 @@ class JobInfo:
119116 environment : Optional [Dict [str , Any ]]
120117 secrets : Optional [Dict [str , Any ]]
121118 flavor : Optional [SpaceHardware ]
122- status : Optional [ JobStatus ]
123- owner : Optional [ JobOwner ]
119+ status : JobStatus
120+ owner : JobOwner
124121
125122 # Inferred fields
126123 endpoint : str
@@ -132,13 +129,15 @@ def __init__(self, **kwargs) -> None:
132129 self .created_at = parse_datetime (created_at ) if created_at else None
133130 self .docker_image = kwargs .get ("dockerImage" ) or kwargs .get ("docker_image" )
134131 self .space_id = kwargs .get ("spaceId" ) or kwargs .get ("space_id" )
135- self .owner = JobOwner (** (kwargs ["owner" ] if isinstance (kwargs .get ("owner" ), dict ) else {}))
132+ owner = kwargs .get ("owner" , {})
133+ self .owner = JobOwner (id = owner ["id" ], name = owner ["name" ], type = owner ["type" ])
136134 self .command = kwargs .get ("command" )
137135 self .arguments = kwargs .get ("arguments" )
138136 self .environment = kwargs .get ("environment" )
139137 self .secrets = kwargs .get ("secrets" )
140138 self .flavor = kwargs .get ("flavor" )
141- self .status = JobStatus (** (kwargs ["status" ] if isinstance (kwargs .get ("status" ), dict ) else {}))
139+ status = kwargs .get ("status" , {})
140+ self .status = JobStatus (stage = status ["stage" ], message = status .get ("message" ))
142141
143142 # Inferred fields
144143 self .endpoint = kwargs .get ("endpoint" , constants .ENDPOINT )
0 commit comments