# Programmatically accessing artifact object very slow for first call for large artifacts

**URL:** <https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158>\
**Category:** W&B Help\
**Created:** [October 29, 2021, 5:07pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158 "2021-10-29T17:07:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicjac](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@nicjac](https://community.wandb.ai/u/nicjac)\
**Post date:** [October 29, 2021, 5:07pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/1 "2021-10-29T17:07:26Z")

</div>

Hello!

I came across this issue recently, and I was wondering whether anything can be done to speed up this process. We are using W&B as source of truth for versioning of our datasets. Each dataset is an artefact in a specific project, and files making up this dataset are added as references (everything is stored on S3).

We sometime need to retrieve the path (including version) to a specific file in the artefact. This is typically very fast (\<1s) but for larger artefact (made up of \>10K references), the process can slow down significantly and take up to 30 seconds. We realized that this holds true whenever we try to access the artifact for the first time (e.g. getting its digest).

Is it expected that artifacts with a large number of files will result in long wait for the first operation when accessing in programmatically in Python?

We typically use the public API to access the artifact (see below for example) but the same happens when using a run.

```auto
api = wandb.Api()
artifact = api.artifact("my_org/my_project/my_artifact:latest")
file_info = artifact.get_path("example_file_in_artifact")
s3_path = file_info.ref
s3_version = file_info.extra["versionID"]

```

Thanks!

Nicolas

---

<div class="post-metadata">

**Author:** ![lesliewandb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/lesliewandb/32/369_2.png) [@lesliewandb](https://community.wandb.ai/u/lesliewandb)\
**Post date:** [November 1, 2021, 1:19pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/2 "2021-11-01T13:19:04Z")

</div>

Hi Nicolas, if the artifact is large, it will take longer for it to download for the first operation. As you already stated, if you indicate the path, it’ll be faster to download, and you can also indicate the type of artifact you want in order to get a specific datatype from the artifact by using the following code:

runs = api.runs(…) for run in runs:  
for artifact in run.logged\_artifacts():  
if artifact.type == “model”:  
artifact.download()

---

<div class="post-metadata">

**Author:** ![nicjac](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@nicjac](https://community.wandb.ai/u/nicjac)\
**Post date:** [November 2, 2021, 5:36pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/3 "2021-11-02T17:36:50Z")

</div>

Hi @Leslie,

Thank you for your reply.

In my case, I am not trying to download the artefact, but merely to get the path to one of the file it includes. It is not obvious to me that the length of this operation should be proportional to the size of the dataset?

Happy to provide more details if useful.

Thanks.

Regards,  
Nicolas

---

<div class="post-metadata">

**Author:** ![lesliewandb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/lesliewandb/32/369_2.png) [@lesliewandb](https://community.wandb.ai/u/lesliewandb)\
**Post date:** [November 4, 2021, 7:16pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/4 "2021-11-04T19:16:48Z")

</div>

Thank you for the clarification. We are currently working on optimizing our artifacts to speed up artifact.get, but yes currently to get the time to get these artifacts is correlated to the size of the artifacts.

---

<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:** [January 1, 2022, 5:36pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/5 "2022-01-01T17:36:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lesliewandb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/lesliewandb/32/369_2.png) [@lesliewandb](https://community.wandb.ai/u/lesliewandb)\
**Post date:** [January 5, 2022, 9:10pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/6 "2022-01-05T21:10:17Z")

</div>

Hi again Nicolas, when our engineers tried to repro this, two artifacts with S3 references (one with 10K and one with 100K), it takes 0.5 seconds and 2 seconds, respectively using the code that is given. Is it possible for you to give us a more detailed script of what you are doing to get this lag?

---

<div class="post-metadata">

**Author:** ![lesliewandb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/lesliewandb/32/369_2.png) [@lesliewandb](https://community.wandb.ai/u/lesliewandb)\
**Post date:** [February 18, 2022, 7:58pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/7 "2022-02-18T19:58:49Z")

</div>

Hi Nicolas,

Is it possible for you to give us a more detailed script so we can fix this issue?

Warmly,  
Leslie

---

<div class="post-metadata">

**Author:** ![lesliewandb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/lesliewandb/32/369_2.png) [@lesliewandb](https://community.wandb.ai/u/lesliewandb)\
**Post date:** [February 22, 2022, 2:12pm UTC](https://community.wandb.ai/t/programmatically-accessing-artifact-object-very-slow-for-first-call-for-large-artifacts/1158/8 "2022-02-22T14:12:55Z")

</div>

Hi Nicolas,

Since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

Warmly,  
Leslie
