# Calling run.history(samples=n\_samples) returns a sample size different from n\_samples

**URL:** <https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414>\
**Category:** W&B Help\
**Tags:** wandb\
**Created:** [November 14, 2022, 2:27pm UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414 "2022-11-14T14:27:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolja](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@kolja](https://community.wandb.ai/u/kolja)\
**Post date:** [November 14, 2022, 2:27pm UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/1 "2022-11-14T14:27:22Z")

</div>

Hi everyone!

I am experiencing weird behaviour of the run.history() function in Python:

Calling `run.history(samples = 100)` gives me sample sizes different to 100 and the sample size varies for each call. E.g. executing it 5 times gave me sample sizes 98, 90, 88, 110, 104.  
However, when I execute `run.history(keys=['my_key'], samples=100)`, I get a sample size of exactly 100 for every call. Why is this the case?

After investigating this further, I found more strange behaviour: Calling `run.history(keys=['my_key'], samples=n_samples)` yields a sample size of exactly n\_samples, as long as n\_samples \<= 12493 (at least for my test run). If n\_samples \> 12493, smaller sample sizes (varying roughly between 12400 and 12490) are returned.

Am I understanding something wrong or are these functions behaving in a way that they shouldn’t?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ramit\_goolry](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@ramit\_goolry](https://community.wandb.ai/u/ramit_goolry)\
**Post date:** [November 18, 2022, 5:08am UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/2 "2022-11-18T05:08:21Z")

</div>

Hi @kolja,

The function is probably not behaving as it is supposed to - I’m going to have to investigate this on my end, but we should expect `run.history(samples = n)` to return `n` values (as long as they exist).

---

<div class="post-metadata">

**Author:** ![ramit\_goolry](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@ramit\_goolry](https://community.wandb.ai/u/ramit_goolry)\
**Post date:** [November 23, 2022, 5:45am UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/3 "2022-11-23T05:45:21Z")

</div>

Hi @kolja,

We wanted to follow up with you regarding your support request as we have not heard back from you. Please let us know if we can be of further assistance or if your issue has been resolved.

---

<div class="post-metadata">

**Author:** ![kolja](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@kolja](https://community.wandb.ai/u/kolja)\
**Post date:** [November 23, 2022, 2:32pm UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/4 "2022-11-23T14:32:21Z")

</div>

Hi @ramit_goolry ,

no unfortunately the issue is still not resolved.

---

<div class="post-metadata">

**Author:** ![ramit\_goolry](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@ramit\_goolry](https://community.wandb.ai/u/ramit_goolry)\
**Post date:** [November 30, 2022, 6:08am UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/5 "2022-11-30T06:08:44Z")

</div>

Hi @kolja,

I apologize about that - that was an automated message that was sent over. Could you try using `run.scan_history()` and let me know if you run into the same behaviour?

Thanks,  
Ramit

---

<div class="post-metadata">

**Author:** ![kolja](https://avatars.discourse-cdn.com/v4/letter/k/a9adbd/32.png) [@kolja](https://community.wandb.ai/u/kolja)\
**Post date:** [November 30, 2022, 4:24pm UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/6 "2022-11-30T16:24:20Z")

</div>

Hi @ramit_goolry ,

`run.scan_history()` per definition returns the full history, not a sampled version. It behaves as expected, but my use case is that I want to downsample long runs to a specific number of samples, so this does not solve my issue.

---

<div class="post-metadata">

**Author:** ![ramit\_goolry](https://avatars.discourse-cdn.com/v4/letter/r/85e7bf/32.png) [@ramit\_goolry](https://community.wandb.ai/u/ramit_goolry)\
**Post date:** [December 13, 2022, 6:06am UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/7 "2022-12-13T06:06:33Z")

</div>

Hey @kolja,

Thanks for the explanation! `run.history()` is not behaving correctly here - I had already filed a bug report for this to be tracked internally. For now, I would suggest using `run.history(keys=['my_key'], samples=100)` in order to get all your metrics in that case.

I will respond back here once this issue has been resolved.

---

<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:** [February 11, 2023, 6:06am UTC](https://community.wandb.ai/t/calling-run-history-samples-n-samples-returns-a-sample-size-different-from-n-samples/3414/8 "2023-02-11T06:06:37Z")

</div>

Closed on February 11, 2023, 6:06am UTC

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