# How do I query whether a run object is disabled (\`RunDisabled\`)?

**URL:** <https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256>\
**Category:** W&B Help\
**Created:** [April 17, 2022, 7:14pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256 "2022-04-17T19:14:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranshadmi-nexite](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@ranshadmi-nexite](https://community.wandb.ai/u/ranshadmi-nexite)\
**Post date:** [April 17, 2022, 7:14pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/1 "2022-04-17T19:14:57Z")

</div>

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’?

---

<div class="post-metadata">

**Author:** ![armanharutyunyan](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@armanharutyunyan](https://community.wandb.ai/u/armanharutyunyan)\
**Post date:** [April 18, 2022, 7:54am UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/2 "2022-04-18T07:54:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ranshadmi-nexite](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@ranshadmi-nexite](https://community.wandb.ai/u/ranshadmi-nexite)\
**Post date:** [April 19, 2022, 4:31pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/4 "2022-04-19T16:31:43Z")

</div>

```auto
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?

---

<div class="post-metadata">

**Author:** ![armanharutyunyan](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@armanharutyunyan](https://community.wandb.ai/u/armanharutyunyan)\
**Post date:** [April 21, 2022, 11:14am UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/5 "2022-04-21T11:14:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ranshadmi-nexite](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@ranshadmi-nexite](https://community.wandb.ai/u/ranshadmi-nexite)\
**Post date:** [April 22, 2022, 3:25pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/6 "2022-04-22T15:25:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![armanharutyunyan](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@armanharutyunyan](https://community.wandb.ai/u/armanharutyunyan)\
**Post date:** [May 3, 2022, 3:42am UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/7 "2022-05-03T03:42:42Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![ranshadmi-nexite](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@ranshadmi-nexite](https://community.wandb.ai/u/ranshadmi-nexite)\
**Post date:** [May 3, 2022, 11:27am UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/8 "2022-05-03T11:27:16Z")

</div>

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):

```auto
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

---

<div class="post-metadata">

**Author:** ![armanharutyunyan](https://avatars.discourse-cdn.com/v4/letter/a/a6a055/32.png) [@armanharutyunyan](https://community.wandb.ai/u/armanharutyunyan)\
**Post date:** [May 5, 2022, 3:27pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/9 "2022-05-05T15:27:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ranshadmi-nexite](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@ranshadmi-nexite](https://community.wandb.ai/u/ranshadmi-nexite)\
**Post date:** [May 5, 2022, 4:47pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/10 "2022-05-05T16:47:51Z")

</div>

No further questions regarding this topic, thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [July 4, 2022, 4:47pm UTC](https://community.wandb.ai/t/how-do-i-query-whether-a-run-object-is-disabled-rundisabled/2256/11 "2022-07-04T16:47:54Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
