Given a run
object (such as the one retuned by wandb.init()
, what’s the right way to query its status?
E.g. `run.status == ‘RunDisabled’?
Hey there,
The run object returned by wandb.init() doesn’t have a state attribute but the run object that is returned by our Public API does.
Here is an example you can use:
api = wandb.Api()
run = api.run(‘entity/project/run_id’)
run.state
Best,
Arman
wandb_run = wandb.init(
entity="my_entity",
project="my_project",
job_type="my_cool_job",
mode="disabled"
)
api = wandb.Api()
run = api.run(f"my_entity/my_project/{wandb_run.id}")
Returns an error: wandb.errors.CommError: Could not find run <Run ... (not found)>
Please advise - am I doing something wrong?
Yes, you are initializing the experiment in disabled mode which will just mock out all the wandb method calls. So the run doesn’t really exist.
Hi Arman,
Sorry, I’m not feeling I’m getting a clear answer here. Let me rephrase my question: Given a run
object as returned by wand.init()
(or a run id
), how do I find out if it’s a valid run (i.e. not disabled
)?
Can you provide a short and concise code to implement this check?
Thanks,
Ran
Hey @ranshadmi-nexite, apologies about the delay on this. I found a workaround for this. You can use this code snippet to check if the run is disabled:
run = wandb.init()
isinstance(run.mode, wandb.sdk.lib.disabled.RunDisabled)
If the run is not disable, run.mode type will be string, if it is disabled, the isinstance call will return True.
Please let me know if this works for you.
Best,
Arman
What you suggest would work. I also found another workaround which doesn’t require the run
variable to be supplied (and is slightly prettier I think):
import wandb
print("active" if isinstance(wandb.run, wandb.sdk.wandb_run.Run) else "inactive")
What do you think?
Anyway I think you guys in W&B need to provide a simpler and more concise API call to get the current run status. Just my thought.
Thanks,
Ran
Yeah that should work as well. Thanks for the feedback @ranshadmi-nexite. I’ll share it with the team. In the meantime i just want to make sure that you don’t have any other questions.
No further questions regarding this topic, thank you.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.