{"id":8070,"date":"2023-11-02T09:24:56","date_gmt":"2023-11-02T17:24:56","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=8070"},"modified":"2025-04-24T17:04:56","modified_gmt":"2025-04-24T17:04:56","slug":"tracking-artifacts-with-comet-ml","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\/","title":{"rendered":"Tracking Artifacts With Comet ML"},"content":{"rendered":"\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\">\n\n\n\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<figure class=\"mk ml mm mn mo mp mh mi paragraph-image\">\n<div class=\"mq mr ee ms bg mt\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg mu mv c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4\" alt=\"\" width=\"700\" height=\"467\"><\/figure><div class=\"mh mi mj\"><picture><\/picture><\/div>\n<\/div><figcaption class=\"mw mx my mh mi mz na be b bf z dw\" data-selectable-paragraph=\"\">Photo by <a class=\"af nb\" href=\"https:\/\/unsplash.com\/@unarchive?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Jeremy Bezanger<\/a> on <a class=\"af nb\" href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Unsplash<\/a><\/figcaption><\/figure>\n<p id=\"4e31\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">All machine learning projects involve searching for the right model and features. As there is no way to know ahead of time what combination will best tackle a problem at hand, several experiments are conducted to try and find a solution worthy of being taken into production. At various steps in the process, you may need to reproduce an experiment: Maybe for auditing purposes, to draw comparisons, learning, etc. This is typically where the problems occur.<\/p>\n<p id=\"f82e\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">Attempting to reconstruct training data, features, models, frameworks, source code, etc., can be absolute hell if everything was not tracked and managed accordingly. In most cases, if you\u2019ve failed to properly track experiments and their artifacts you\u2019re going to struggle to reproduce them if it\u2019s possible. The result is a whole lot of time wasted with not much to show for it.<\/p>\n<p id=\"818c\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">Welcome the <code class=\"cw nx ny nz oa b\">Artifact<\/code> class in <a class=\"af nb\" href=\"https:\/\/www.comet.com\/site\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Comet ML<\/a>.<\/p>\n<p id=\"8d98\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">In this article, we are going to discover how to do the following leveraging Comet ML:<br>\n\u2192 How to add an asset to an Artifact<br>\n\u2192 How to retrieve a logged Artifact<br>\n\u2192 How to update the version of an Artifact<\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<h1 id=\"cc5f\" class=\"oj ok fr be ol om on gr oo op oq gu or os ot ou ov ow ox oy oz pa pb pc pd pe bj\" data-selectable-paragraph=\"\">Adding an Artifact<\/h1>\n<p id=\"24a7\" class=\"pw-post-body-paragraph nc nd fr be b gp pf nf ng gs pg ni nj nk ph nm nn no pi nq nr ns pj nu nv nw fk bj\" data-selectable-paragraph=\"\">Let\u2019s be clear on what we are talking about when we say \u201cartifacts.\u201d An Artifact describes outputs that are created during the training process. This could be anything from a fully trained model, a models checkpoint, the data used to train a model, etc. We keep them to aid us with reproducibility.<\/p>\n<p id=\"2145\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\"><em class=\"pk\">An artifact is \u201csomething observed in a scientific investigation or experiment that is not naturally present but occurs as a result of the preparative or investigative procedure.\u201d \u2014 <\/em><a class=\"af nb\" href=\"https:\/\/www.google.com\/search?q=artifact+meaning&amp;rlz=1C1CHBF_en-GBGB921GB921&amp;sxsrf=APq-WBvlJ4QBP8fFoi8M4lN83Ep_fd32lQ%3A1645181681925&amp;ei=8XoPYqTTN4_2gAaZvrnYCw&amp;ved=0ahUKEwjkj_eti4n2AhUPO8AKHRlfDrsQ4dUDCA4&amp;uact=5&amp;oq=artifact+meaning&amp;gs_lcp=Cgdnd3Mtd2l6EAMyCQgjECcQRhD5ATIGCAAQBxAeMgYIABAHEB4yBggAEAcQHjIFCAAQgAQyBggAEAcQHjIFCAAQgAQyBQgAEIAEMgUIABCABDIGCAAQBxAeOgcIIxCwAxAnOgcIABBHELADOgcIABCwAxBDOgcIABCABBAKOgkIABANEEYQ-QE6CAgAEAcQChAeOgQIABANOgcIIxCwAhAnOgcIIxCxAhAnSgQIQRgASgQIRhgAUMMFWJkYYPoZaARwAXgAgAFSiAGSBZIBAjEwmAEAoAEByAEKwAEB&amp;sclient=gws-wiz\" target=\"_blank\" rel=\"noopener ugc nofollow\"><strong class=\"be pl\"><em class=\"pk\">Dictionary<\/em><\/strong><\/a><strong class=\"be pl\"><em class=\"pk\"> definition<\/em><\/strong><\/p>\n<p id=\"6843\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">In Comet, each artifact lives in your workspace. They are distinguished by a name, and if there are many versions of an artifact, it can also be told apart by its version number.<\/p>\n<figure class=\"mk ml mm mn mo mp mh mi paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg mu mv c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:600\/1*r_9wyM5ScrTeBzxcNAeMmg.gif\" alt=\"\" width=\"600\" height=\"338\"><\/figure><div class=\"mh mi pm\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1200\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 1200w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 600px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1200\/1*r_9wyM5ScrTeBzxcNAeMmg.gif 1200w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 600px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"mw mx my mh mi mz na be b bf z dw\" data-selectable-paragraph=\"\"><strong class=\"be pl\">Demonstration of Comet Workspace and artifacts<\/strong><\/figcaption>\n<\/figure>\n<p id=\"7350\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">Logging an A<a class=\"af nb\" href=\"https:\/\/www.comet.com\/site\/artifacts\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">rtifact<\/a> is made simple with the <code class=\"cw nx ny nz oa b\">Artifact()<\/code> class. Each instance must be initialized with a name (to separate distinct artifacts), and a type (i.e. dataset, model, etc). You may also pass other information such as:<\/p>\n<ul class=\"\">\n<li id=\"5b89\" class=\"nc nd fr be b gp ne nf ng gs nh ni nj nk pn nm nn no po nq nr ns pp nu nv nw pq pr ps bj\" data-selectable-paragraph=\"\"><strong class=\"be pl\">Version <\/strong>\u2192 To tell Comet what version number to create. Note, if a version isn\u2019t manually passed, Comet will automatically create one for you. It will do so by checking whether it\u2019s the first time you\u2019ve logged the artifact (using the name as a unique identifier) and logging the correct version accordingly.<\/li>\n<li id=\"e260\" class=\"nc nd fr be b gp pt nf ng gs pu ni nj nk pv nm nn no pw nq nr ns px nu nv nw pq pr ps bj\" data-selectable-paragraph=\"\"><strong class=\"be pl\">Aliases <\/strong>\u2192 To be attached to the future artifact version. The aliases list is converted to a set data type for de-duplication.<\/li>\n<li id=\"8f29\" class=\"nc nd fr be b gp pt nf ng gs pu ni nj nk pv nm nn no pw nq nr ns px nu nv nw pq pr ps bj\" data-selectable-paragraph=\"\"><strong class=\"be pl\">Metadata<\/strong> \u2192 To add more information about the artifact being logged. The metadata must be a JSON-encodable dictionary.<\/li>\n<\/ul>\n<p id=\"d08d\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">The <a class=\"af nb\" href=\"https:\/\/www.comet.com\/docs\/python-sdk\/artifacts-overview\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">documentation<\/a> states the following:<\/p>\n<p id=\"0072\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\"><em class=\"pk\">\u201cAfter creating an Artifact instance, you then can add asset files or a remote URL to the Artifact.\u201d<\/em><\/p>\n<p id=\"cdbb\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">Let\u2019s see this in action:<\/p>\n<pre># initialize artifacts\ntrain_data_artifact = comet_ml.Artifact(name=\"training_data\",\n                                        artifact_type=\"dataset\",\n                                        metadata={\"current_data\": datetime.datetime.utcnow().isoformat()})\ntrain_labels_artifact = comet_ml.Artifact(name=\"training_labels\",\n                                        artifact_type=\"dataset\",\n                                        metadata={\"current_data\": datetime.datetime.utcnow().isoformat()})\n\nvalidation_data_artifact = comet_ml.Artifact(name=\"validation_data\",\n                                             artifact_type=\"dataset\",\n                                             metadata={\"current_date\": datetime.datetime.utcnow().isoformat()})\n\nvalidation_labels_artifact = comet_ml.Artifact(name=\"validation_labels\",\n                                             artifact_type=\"dataset\",\n                                             metadata={\"current_date\": datetime.datetime.utcnow().isoformat()})\n\nfor i in range(5):\n  experiment = comet_ml.Experiment(\n    api_key=\"KGsg6IUGc5FpgH2lp3uF2gMbv\",\n    project_name=\"testing-comet-experiments\",\n    auto_param_logging=True,\n    auto_histogram_weight_logging=True,\n    auto_histogram_gradient_logging=True,\n    auto_histogram_activation_logging=True,\n    auto_histogram_epoch_rate=True\n    )\n\n  model_artifact = comet_ml.Artifact(name=f\"model_{i}\",\n                                     artifact_type=\"model\",\n                                     metadata={\"current_date\": datetime.datetime.utcnow().isoformat()})\n\n  # model training\n  with experiment.train():\n    seed = np.random.randint(low=0, high=1000, dtype=int)\n\n    np.random.seed(seed)\n    tf.random.set_seed(seed)\n    random.seed(seed)\n\n    experiment.log_parameter(\"random_seed\", seed)\n\n    model.fit(X_train, y_train, epochs=50, verbose=0)\n    model.save(f\"my_model_{i}.h5\")\n\n    # adding the artifact\n    model_artifact.add(f\"my_model_{i}.h5\")\n    experiment.log_artifact(model_artifact)\n\n    if i==0:\n      np.savetxt(\"training_data.txt\", X_train)\n      np.savetxt(\"training_labels.txt\", y_train)\n      np.savetxt(\"validation_data.txt\", X_val)\n      np.savetxt(\"validation_labels.txt\", y_val)\n\n      # adding data\n      train_data_artifact.add(\"training_data.txt\")\n      train_labels_artifact.add(\"training_labels.txt\")\n      validation_data_artifact.add(\"validation_data.txt\")\n      validation_labels_artifact.add(\"validation_labels.txt\")\n\n      # logging each artifact\n      experiment.log_artifact(train_data_artifact)\n      experiment.log_artifact(train_labels_artifact)\n      experiment.log_artifact(validation_data_artifact)\n      experiment.log_artifact(validation_labels_artifact)\n\n  # model validation\n  with experiment.validate():\n    loss, acc = model.evaluate(X_val, y_val)\n\n    experiment.log_metric(\"loss\", loss)\n    experiment.log_metric(\"accuracy\", acc)\n\n    experiment.end()<\/pre>\n<p id=\"dfc4\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">I know what you\u2019re thinking \u2014 \u201cthat\u2019s a lot of code.\u201d Don\u2019t worry I\u2019ll break it down.<\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<blockquote class=\"qb\"><p id=\"eebd\" class=\"qc qd fr be qe qf qg qh qi qj qk nw dw\" data-selectable-paragraph=\"\">Getting started with Comet is completely free \u2014 c<a class=\"af nb\" href=\"https:\/\/www.comet.com\/site\/artifacts\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">heck out Artifacts for yourself today.<\/a><\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<p id=\"bac7\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">The first section shows us initializing lots of data artifacts. We\u2019ve done this because we want to save our training data with labels, and likewise for the validation set.<span style=\"font-family: var(--wpex-body-font-family, var(--wpex-font-sans)); font-size: var(--wpex-body-font-size, 13px);\">&nbsp;<\/span><\/p>\n<pre># initialize artifacts\ntrain_data_artifact = comet_ml.Artifact(name=\"training_data\",\n                                        artifact_type=\"dataset\",\n                                        metadata={\"current_data\": datetime.datetime.utcnow().isoformat()})\ntrain_labels_artifact = comet_ml.Artifact(name=\"training_labels\",\n                                        artifact_type=\"dataset\",\n                                        metadata={\"current_data\": datetime.datetime.utcnow().isoformat()})\n\nvalidation_data_artifact = comet_ml.Artifact(name=\"validation_data\",\n                                             artifact_type=\"dataset\",\n                                             metadata={\"current_date\": datetime.datetime.utcnow().isoformat()})\n\nvalidation_labels_artifact = comet_ml.Artifact(name=\"validation_labels\",\n                                             artifact_type=\"dataset\",\n                                             metadata={\"current_date\": datetime.datetime.utcnow().isoformat()})<\/pre>\n<p id=\"a2e3\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">Next, we start a for loop. This is done so we can generate five different neural network architectures, thus, conducting five experiments. Notice that the beginning of each loop initialized a new <code class=\"cw nx ny nz oa b\">Experiment()<\/code> and <code class=\"cw nx ny nz oa b\">Artifact()<\/code>instance. We do this to let Comet know we are starting a new experiment and would like to save a new model artifact \u2014 if we didn\u2019t do this it would update old versions.<span style=\"font-family: var(--wpex-body-font-family, var(--wpex-font-sans)); font-size: var(--wpex-body-font-size, 13px);\">&nbsp;<\/span><\/p>\n<pre>for i in range(5):\n  experiment = comet_ml.Experiment(\n    api_key=\"KGsg6IUGc5FpgH2lp3uF2gMbv\",\n    project_name=\"testing-comet-experiments\",\n    auto_param_logging=True,\n    auto_histogram_weight_logging=True,\n    auto_histogram_gradient_logging=True,\n    auto_histogram_activation_logging=True,\n    auto_histogram_epoch_rate=True\n    )\n\n  model_artifact = comet_ml.Artifact(name=f\"model_{i}\",\n                                     artifact_type=\"model\",\n                                     metadata={\"current_date\": datetime.datetime.utcnow().isoformat()})<\/pre>\n<p id=\"03a3\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">After that, we begin our training and validation experiments respectively. To add an artifact to an Artifact instance, we must pass either a file path or a file-like asset. This is why we saved our model after training using <code class=\"cw nx ny nz oa b\">model.save()<\/code>, before adding it to the Artifact instance.<\/p>\n<p id=\"c02a\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">A similar procedure was followed for the train data\/labels and validation data\/labels \u2014 each array was saved with <code class=\"cw nx ny nz oa b\">np.savetxt()<\/code>. But since each model is seeing the same data (train and validation), we set a condition to only log it once.<\/p>\n<pre>  # model training\n  with experiment.train():\n    seed = np.random.randint(low=0, high=1000, dtype=int)\n\n    np.random.seed(seed)\n    tf.random.set_seed(seed)\n    random.seed(seed)\n\n    experiment.log_parameter(\"random_seed\", seed)\n\n    model.fit(X_train, y_train, epochs=50, verbose=0)\n    model.save(f\"my_model_{i}.h5\")\n\n    # adding the artifact\n    model_artifact.add(f\"my_model_{i}.h5\")\n    experiment.log_artifact(model_artifact)\n\n    if i==0:\n      np.savetxt(\"training_data.txt\", X_train)\n      np.savetxt(\"training_labels.txt\", y_train)\n      np.savetxt(\"validation_data.txt\", X_val)\n      np.savetxt(\"validation_labels.txt\", y_val)\n\n      # adding data\n      train_data_artifact.add(\"training_data.txt\")\n      train_labels_artifact.add(\"training_labels.txt\")\n      validation_data_artifact.add(\"validation_data.txt\")\n      validation_labels_artifact.add(\"validation_labels.txt\")\n\n      # logging each artifact\n      experiment.log_artifact(train_data_artifact)\n      experiment.log_artifact(train_labels_artifact)\n      experiment.log_artifact(validation_data_artifact)\n      experiment.log_artifact(validation_labels_artifact)<\/pre>\n<p id=\"52fc\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">That\u2019s all that\u2019s happening.<\/p>\n<h1 id=\"af18\" class=\"oj ok fr be ol om ql gr oo op qm gu or os qn ou ov ow qo oy oz pa qp pc pd pe bj\" data-selectable-paragraph=\"\">Retrieving a Logged Artifact<\/h1>\n<p id=\"71a4\" class=\"pw-post-body-paragraph nc nd fr be b gp pf nf ng gs pg ni nj nk ph nm nn no pi nq nr ns pj nu nv nw fk bj\" data-selectable-paragraph=\"\">In our last run, we stored several different Artifacts. At some point, we may be required to retrieve them from our workspace. This action is done using the <code class=\"cw nx ny nz oa b\">get_artifact()<\/code> method on our <code class=\"cw nx ny nz oa b\">Experiment()<\/code> instance. The method takes the unique Artifact name and workspace.<\/p>\n<blockquote class=\"qq qr qs\"><p id=\"7358\" class=\"nc nd pk be b gp ne nf ng gs nh ni nj qt nl nm nn qu np nq nr qv nt nu nv nw fk bj\" data-selectable-paragraph=\"\"><strong class=\"be pl\">Note<\/strong>: you may also retrieve a specific artifact version by setting the version_or_alias attribute to the appropriate version. Leaving it blank will retrieve the latest version.<\/p><\/blockquote>\n<pre>experiment = comet_ml.Experiment(api_key=\"KGsg6IUGc5FpgH2lp3uF2gMbv\")\n\nartifact_model_3 = experiment.get_artifact(artifact_name=\"model_3\",\n                                           workspace=\"kurtispykes\")<\/pre>\n<p id=\"d134\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">To see all of the logged assets for an artifact version, we can use the <code class=\"cw nx ny nz oa b\">assets<\/code>attribute of an <code class=\"cw nx ny nz oa b\">Experiment()<\/code> instance as seen below.<span style=\"font-family: var(--wpex-body-font-family, var(--wpex-font-sans)); font-size: var(--wpex-body-font-size, 13px);\">&nbsp;<\/span><\/p>\n<pre>for asset in artifact_model_3.assets:\n  print(f\"Logical path: {asset.logical_path}\\n\\\n  Size: {asset.size}\\n\\\n  Metadata: {asset.metadata}\\n\\\n  Type: {asset.asset_type}\\n\\\n  Artifact ID: {asset.artifact_id}\\n\\\n  ID: {asset.id}\\n\\\n  Version: {asset.artifact_version_id}\")<\/pre>\n<p id=\"3dda\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">And this will output the following:<\/p>\n<pre class=\"mk ml mm mn mo qw oa qx qy ax qz bj\"><span id=\"a035\" class=\"ra ok fr oa b ic rb rc l is rd\" data-selectable-paragraph=\"\"><strong class=\"oa fs\">Logical <\/strong>path: my_model_3.h5\n<strong class=\"oa fs\">Size<\/strong>: 33384\n<strong class=\"oa fs\">Metadata<\/strong>: None\n<strong class=\"oa fs\">Type<\/strong>: unknown\n<strong class=\"oa fs\">Artifact <\/strong>ID: 0c433884-b586-47a5-bf21-c841c8dc9733\n<strong class=\"oa fs\">ID<\/strong>: c27a83b616284beeafc91c69c1952df2\n<strong class=\"oa fs\">Version<\/strong>: 5fbcb375-bf52-47f9-a9f1-9e87fed09a25<\/span><\/pre>\n<h1 id=\"e03f\" class=\"oj ok fr be ol om ql gr oo op qm gu or os qn ou ov ow qo oy oz pa qp pc pd pe bj\" data-selectable-paragraph=\"\">Updating a Logged Artifact<\/h1>\n<p id=\"3fac\" class=\"pw-post-body-paragraph nc nd fr be b gp pf nf ng gs pg ni nj nk ph nm nn no pi nq nr ns pj nu nv nw fk bj\" data-selectable-paragraph=\"\">Now, let\u2019s say you&#8217;ve got some new data and you want to add it to the training data Artifact, how do we do that? Simple. We retrieve an existing Artifact, add the new file, bump the version, then log it \u2014 see the code below.<\/p>\n<pre># generating new instances\nX, y = make_circles(\n    n_samples=200, noise=0.05, random_state=42\n)\n\n# retrieve old training data\nexperiment = comet_ml.Experiment(api_key=\"KGsg6IUGc5FpgH2lp3uF2gMbv\")\ntrain_data_artifact = experiment.get_artifact(artifact_name=\"training_data\",\n                                              workspace=\"kurtispykes\")\ntrain_labels_artifact = experiment.get_artifact(artifact_name=\"training_labels\",\n                                              workspace=\"kurtispykes\")\n\n# download non-remote assets to local disk\nlocal_train_data_artifact = train_data_artifact.download(\"new_data\")\nlocal_train_labels_artifact = train_labels_artifact.download(\"new_labels\")\n\n# loading the data from a txt file\ntrain_data = np.genfromtxt(\"new_data\/training_data.txt\")\ntrain_labels = np.genfromtxt(\"new_labels\/training_labels.txt\")\n\n# joining the new data to old data\ntrain_data_updated = np.concatenate((X_train, X), axis=0)\ntrain_labels_updated = np.concatenate((y_train, y), axis=0)\n\n# saving the updated data locally\nnp.savetxt(\"updated_training_data.txt\", X_train)\nnp.savetxt(\"updated_training_labels.txt\", y_train)\n\n# logging the updated data artifacts\nlocal_train_data_artifact.add(\"updated_training_data.txt\")\nlocal_train_labels_artifact.add(\"updated_training_labels.txt\")\n\n# bumping the version\nlocal_train_data_artifact.version = train_data_artifact.version.next_minor()\nlocal_train_labels_artifact.version = train_labels_artifact.version.next_minor()\n\n# logging the artifacts\nexperiment.log_artifact(local_train_data_artifact)\nexperiment.log_artifact(local_train_labels_artifact)<\/pre>\n<p id=\"4079\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">When we visit our workspace, we will see there has been a new version added.<\/p>\n<figure class=\"mk ml mm mn mo mp mh mi paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg mu mv c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:600\/1*OIgUkyPqof4Ihk9trgudTw.gif\" alt=\"\" width=\"600\" height=\"338\"><\/figure><div class=\"mh mi pm\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*OIgUkyPqof4Ihk9trgudTw.gif 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*OIgUkyPqof4Ihk9trgudTw.gif 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*OIgUkyPqof4Ihk9trgudTw.gif 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*OIgUkyPqof4Ihk9trgudTw.gif 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*OIgUkyPqof4Ihk9trgudTw.gif 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*OIgUkyPqof4Ihk9trgudTw.gif 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1200\/1*OIgUkyPqof4Ihk9trgudTw.gif 1200w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 600px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*OIgUkyPqof4Ihk9trgudTw.gif 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*OIgUkyPqof4Ihk9trgudTw.gif 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*OIgUkyPqof4Ihk9trgudTw.gif 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*OIgUkyPqof4Ihk9trgudTw.gif 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*OIgUkyPqof4Ihk9trgudTw.gif 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*OIgUkyPqof4Ihk9trgudTw.gif 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1200\/1*OIgUkyPqof4Ihk9trgudTw.gif 1200w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 600px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"mw mx my mh mi mz na be b bf z dw\" data-selectable-paragraph=\"\"><strong class=\"be pl\">Viewing the artifact we just added<\/strong><\/figcaption>\n<\/figure>\n<p id=\"a314\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\">That\u2019s all folks!<\/p>\n<p id=\"1368\" class=\"pw-post-body-paragraph nc nd fr be b gp ne nf ng gs nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw fk bj\" data-selectable-paragraph=\"\"><em class=\"pk\">Thanks for reading.<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Photo by Jeremy Bezanger on Unsplash All machine learning projects involve searching for the right model and features. As there is no way to know ahead of time what combination will best tackle a problem at hand, several experiments are conducted to try and find a solution worthy of being taken into production. At various [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[9,7],"tags":[],"coauthors":[138],"class_list":["post-8070","post","type-post","status-publish","format-standard","hentry","category-product","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Tracking Artifacts With Comet ML - Comet<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tracking Artifacts With Comet ML\" \/>\n<meta property=\"og:description\" content=\"Photo by Jeremy Bezanger on Unsplash All machine learning projects involve searching for the right model and features. As there is no way to know ahead of time what combination will best tackle a problem at hand, several experiments are conducted to try and find a solution worthy of being taken into production. At various [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-02T17:24:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:04:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4\" \/>\n<meta name=\"author\" content=\"Kurtis Pykes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kurtis Pykes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Tracking Artifacts With Comet ML - Comet","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml","og_locale":"en_US","og_type":"article","og_title":"Tracking Artifacts With Comet ML","og_description":"Photo by Jeremy Bezanger on Unsplash All machine learning projects involve searching for the right model and features. As there is no way to know ahead of time what combination will best tackle a problem at hand, several experiments are conducted to try and find a solution worthy of being taken into production. At various [&hellip;]","og_url":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2023-11-02T17:24:56+00:00","article_modified_time":"2025-04-24T17:04:56+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4","type":"","width":"","height":""}],"author":"Kurtis Pykes","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Kurtis Pykes","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\/"},"author":{"name":"Team Comet Digital","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/6266601170c60a7a82b3e0043fbe8ddf"},"headline":"Tracking Artifacts With Comet ML","datePublished":"2023-11-02T17:24:56+00:00","dateModified":"2025-04-24T17:04:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\/"},"wordCount":882,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4","articleSection":["Product","Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml\/","url":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml","name":"Tracking Artifacts With Comet ML - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4","datePublished":"2023-11-02T17:24:56+00:00","dateModified":"2025-04-24T17:04:56+00:00","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*QOhDWF6sla2bkUj4"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/tracking-artifacts-with-comet-ml#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Tracking Artifacts With Comet ML"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/6266601170c60a7a82b3e0043fbe8ddf","name":"Team Comet Digital","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/4f0c0a8cc7c0e87c636ff6a420a6647c","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/Screen-Shot-2023-08-12-at-8.58.50-AM-96x96.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/Screen-Shot-2023-08-12-at-8.58.50-AM-96x96.png","caption":"Team Comet Digital"},"sameAs":["https:\/\/www.comet.ml\/"],"url":"https:\/\/www.comet.com\/site\/blog\/author\/teamcometdigital\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/8070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=8070"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/8070\/revisions"}],"predecessor-version":[{"id":15473,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/8070\/revisions\/15473"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=8070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=8070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=8070"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=8070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}