{"id":18300458,"url":"https://github.com/comet-ml/cometr","last_synced_at":"2026-03-06T05:08:26.654Z","repository":{"id":43412702,"uuid":"246712286","full_name":"comet-ml/cometr","owner":"comet-ml","description":"Comet SDK for R","archived":false,"fork":false,"pushed_at":"2023-10-19T17:36:08.000Z","size":722,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T02:54:46.473Z","etag":null,"topics":["comet","data-science","machine-learning"],"latest_commit_sha":null,"homepage":"https://www.comet.com","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/comet-ml.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-12T00:58:51.000Z","updated_at":"2023-11-19T08:37:54.000Z","dependencies_parsed_at":"2024-11-05T15:13:04.352Z","dependency_job_id":"5931f940-68be-4983-a4ca-5c6bbe577e0c","html_url":"https://github.com/comet-ml/cometr","commit_stats":{"total_commits":178,"total_committers":6,"mean_commits":"29.666666666666668","dds":0.2415730337078652,"last_synced_commit":"8933af9b517c4838d4b13e9e76df63b8b36b844e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fcometr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fcometr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fcometr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/comet-ml%2Fcometr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/comet-ml","download_url":"https://codeload.github.com/comet-ml/cometr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247342720,"owners_count":20923643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comet","data-science","machine-learning"],"created_at":"2024-11-05T15:12:31.323Z","updated_at":"2026-03-06T05:08:26.620Z","avatar_url":"https://github.com/comet-ml.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cometr - Comet API for R\n\n[![CRAN version](https://www.r-pkg.org/badges/version/cometr)](https://cran.r-project.org/package=cometr)\n[![R](https://github.com/comet-ml/cometr/actions/workflows/r.yml/badge.svg?branch=master)](https://github.com/comet-ml/cometr/actions/workflows/r.yml)\n\n[Comet](https://www.comet.com/) is a cloud platform allowing you to track, compare, explain and optimize machine learning experiments and models. If you perform any machine learning in R, you can use the `cometr` R package to create and track Comet experiments. All experiment data is available for retrieval through `cometr` or can be viewed on the [Comet dashboard](https://www.comet.com/).\n\nYou can read more about Comet to see its full capabilities on [Comet's website](https://www.comet.com/). The package currently supports Comet's REST API v2.\n\n## Installation\n\nTo install the stable CRAN version:\n\n```R\ninstall.packages(\"cometr\")\n```\n\nTo install the latest development version from GitHub:\n\n```R\ninstall.packages(\"remotes\")\nremotes::install_github(\"comet-ml/cometr\")\n```\n\n## One-time setup\n\nTo use `cometr`, you must first have a [Comet](https://www.comet.com/) account (you can sign up for a free account) and obtain your personal API key from the 'Settings' page on Comet's website. The API key can either be passed into every `cometr` function call as an argument, or it can be defined as a configuration variable as described later in the 'Configuration variables' section.\n\n## How to use\n\n`cometr` is most useful when used in an R script that is run using the `Rscript` tool. It can also be used in interactive environments (such as the R shell or RStudio). To use Comet in your R script, you need to first load `cometr` and create a Comet Experiment by calling `create_experiment()`.\n\n```R\nlibrary(cometr)\nAPI_KEY \u003c- \"\u003cyour API key\u003e\"\nexp \u003c- create_experiment(experiment_name = \"my-first-experiment\",\n                         project_name = \"project1\",\n                         workspace_name = \"daattali\",\n                         api_key = API_KEY)\n```\n\nYou'll see a message displayed with a URL where you can view this newly created Experiment online.\n\n```\nExperiment created: https://www.comet.com/daattali/project1/46d53bbce4e14fb692585b6e73da6e0c\n```\n\nBy default, creating an experiment will log your system's details to Comet's servers, keep track of how long your experiment is running for, log any output that gets generated, and perform a few more house-keeping tasks automatically. You can run `?cometr::create_experiment` to see all the supported features and turn them on or off. \n\nNow that an Experiment object has been created, you can run your machine learning code as usual. The `exp` variable you created is an Experiment object (which is an R6 object--if you don't know what that means then don't worry about it!), and we can use it to set parameters of the experiment and to retrieve information from it. To see all the methods that are supported on Experiment objects, run `?cometr::Experiment`.\n\nHere is an example of how you can use the `exp` object to set or retrieve experiment information:\n\n```R\n\u003e exp$get_key()\n[1] \"46d53bbce4e14fb692585b6e73da6e0c\"\n\u003e exp$log_metric(\"metric1\", 5, step = 1)\n\u003e exp$log_metric(\"metric1\", 10, step = 2)\n\u003e exp$log_graph('{\"nodes\":[[\"a\"],[\"b\"],[\"c\"]],\"edges\":[[\"a,b\"],[\"c,a\"]]}')\n\u003e str(exp$get_metrics_summary())\nList of 1\n $ values:List of 1\n  ..$ :List of 10\n  .. ..$ name            : chr \"metric1\"\n  .. ..$ valueMax        : chr \"10.0\"\n  .. ..$ valueMin        : chr \"5.0\"\n  .. ..$ valueCurrent    : chr \"10.0\"\n  .. ..$ timestampMax    : num 1.59e+12\n  .. ..$ timestampMin    : num 1.59e+12\n  .. ..$ timestampCurrent: num 1.59e+12\n  .. ..$ stepMax         : int 2\n  .. ..$ stepMin         : int 1\n  .. ..$ stepCurrent     : int 2\n\u003e exp$get_graph()\n$graph\n[1] \"{\\\"nodes\\\":[[\\\"a\\\"],[\\\"b\\\"],[\\\"c\\\"]],\\\"edges\\\":[[\\\"a,b\\\"],[\\\"c,a\\\"]]}\"\n```\n\nA Comet Experiment will automatically end when the R script that created it finishes running. However, it's recommended to explicitly stop the experiment with `exp$stop()`.\n\nWhile the Experiment object and its associated functions are the cornerstone of `cometr`, there are other functions that aren't directly related to a specific experiment, such as `get_workspaces()`, `get_projects()`, `get_experiments()`, `create_project()`, `delete_project()`.\n\n```R\n\u003e get_workspaces(api_key = API_KEY)\n$workspaceNames\n$workspaceNames[[1]]\n[1] \"cometrtestws\"\n\n$workspaceNames[[2]]\n[1] \"daattali\"\n```\n\n### Comet Artifacts Support\n\nComet Artifacts allow you to keep track of any data associated with the ML Lifecycle. Depending on your application you might decide to either upload the dataset directly to Comet or using the Remote Artifacts feature to store a reference to it instead. No matter the option you choose, Comet will maintain the lineage between your datasets and the training runs that created or consumed them.\n\nArtifacts live at a Comet Workspace level and are identified by their name. Each Artifact can have multiple versions allowing you to keep track of exactly which dataset was used.\n\n#### Logging an Artifact\n\nLogging an Artifact has three steps:\n\n* Create an Artifact Version\n* Add files and folders to this Artifact Version\n* Logging this Artifact Version to an Experiment\n\n**Log an Artifact to Comet**\n\nWhen you are ready to send the Artifact to Comet, you will log it with `Experiment$log_artifact(ARTIFACT)`.\n\nHere is an example of how you can use the `exp` object to log Comet artifact:\n\n```R\nmetadata \u003c- list(foo=\"bar\")\ntags \u003c- list(\"tag1\", \"tag2\")\naliases \u003c- list(\"alias1\", \"alias2\")\nremote_uri \u003c- \"http://localhost/dataset.dat\"\nartifact \u003c- create_artifact(artifact_name = \"artifact-name\",\n                            artifact_type = \"dataset\",\n                            metadata = metadata,\n                            aliases = aliases,\n                            version_tags = tags)\n\n# Add remote asset to the Artifact                            \nartifact$add_remote(uri = remote_uri,\n                   logical_path = \"dataset\",\n                   metadata = metadata)\n\n# Add local folder to the Artifact\nartifact$add(local_path = \"./data-folder\",\n             logical_path = \"data-files\",\n             metadata = metadata)\n\n# Add single file to the Artifact\nartifact$add(local_path = \"./sample-script.R\",\n            logical_path = \"samle-code\",\n            metadata = metadata)\n             \nexp$log_artifact(artifact)\n```\n\nThe code above will create new Comet Artifact. After that remote and local assets will be added to it and Artifact with all assets will be uploaded to Comet.\n\n**Access a logged Artifact version**\n\nYou can retrieve a logged Artifact from any workspace that you have permission to access, and a workspace name with the `Experiment$get_artifact()` method:\n\n```R\nlogged_artifact \u003c- exp$get_artifact(artifact_name=NAME,\n                                    workspace=WORKSPACE,\n                                    version_or_alias=VERSION_OR_ALIAS)\n```\n\nTo make it easier to access the artifact, you can retrieve a logged Artifact in three ways:\n\n* Get the latest Artifact version by leaving out the `version_or_alias` arguments.\n* Get a specific Artifact version by passing in the `version_or_alias` argument.\n* Get an aliased Artifact version by passing in the `version_or_alias` argument.\n* Get a specific Artifact version by passing in the `artifact_name` in the form of full name of the Artifact and leaving out the other arguments.\n\nThe full name of the Artifact has the following format `workspace/artifact-name:version_or_alias` and can take the following forms as an example:\n\n* `workspace\\artifact-name:2.0.0` - will get the `2.0.0` version of the artifact `artifact-name` from workspace `workspace`\n* `artifact-name:2.0.0` - will get the `2.0.0` version of the artifact `artifact-name` from default user's workspace\n* `artifact-name` - will get the latest version of the artifact `artifact-name` from default user's workspace\n\nYou can also use an alias for a specific version of the Artifact in the above examples instead of the semantic version if you prefer.\n\n#### Download an Artifact\n\nThe process of using an Artifact is similar to the one used to create it.\n\nHere is an example you can use `logged_artifact` to download its content into local folder:\n\n```R\nartifact \u003c- logged_artifact$download(path = \"./data\", overwrite_strategy = FALSE)\n```\n\nWhere `overwrite_strategy` defines how existing files should be handled:\n\n* `FALSE` or `\"FAIL\"`: If a file already exists and its content is different, raise an error.\n* `\"PRESERVE\"`: If a file already exists and its content is different, show a WARNING but preserve the existing content.\n* `TRUE` or `\"OVERWRITE\"`: If a file already exists and its content is different, replace it by the asset version asset.\n\n#### Learn more\n\nYou can find more details about Comet Artifacts at:\n\n* [Use Artifacts](https://www.comet.com/docs/v2/guides/data-management/using-artifacts/): an overview of the Comet Artifacts feature.\n* [Artifacts UI](https://www.comet.com/docs/v2/guides/comet-dashboard/artifacts/): Artifacts pages in the Comet UI.\n\n## Configuration variables\n\nSince it can get tedious to repeat the `api_key` in different function calls, and it can also be a security concern to include the API key in your code, you can set the API key and a few other variables as `cometr` configuration variables.\n\nThe following table lists all the configuration variables that `cometr` uses. All of these variables are optional.\n\n| Variable | Description |\n|---|---|\n| `COMET_API_KEY` | Personal Comet API key to use in every function that accepts an `api_key` parameter. \\*\\*\\* |\n| `COMET_WORKSPACE` | Default workspace to use in every function that accepts a `workspace_name` parameter. \\*\\*\\* |\n| `COMET_PROJECT_NAME` | Default project to use in every function that accepts a `project_name` parameter. \\*\\*\\* |\n| `COMET_LOGGING_FILE` | File to store detailed logs produced by `cometr`. This is mostly useful for troubleshooting. |\n| `COMET_LOGGING_FILE_LEVEL` | If a logging file is provided, set the level of information to log. Must be one of \"DEBUG\", \"INFO\", \"ERROR\". |\n| `COMET_URL_OVERRIDE` | Custom Comet API URL, if you have one. |\n\n_\\*\\*\\* If this value is not provided as a configuration variable, it must be provided as an argument to the relevant functions. If a value is provided as an argument directly to the function, that argument takes precedence and the configuration value is ignored._\n\nConfiguration variables can be set either as environment variables or in a `cometr` config file.\n\nA `cometr` config file is a YAML file named `.comet.yml` that can be defined either in the current working directory or in the user's home directory. For example, a `cometr` config file that defines a default workspace and a default project could look like this:\n\n```yml\nCOMET_WORKSPACE: my_workspace\nCOMET_PROJECT_NAME: my_project\n```\n\nIf a configuration variable is defined in multiple places, then the order of precedence is as follows:\n\n1. Function argument, if relevant (for API keys, workspace name, project name)\n2. Environment variable\n3. `.comet.yml` config file in the local working directory\n4. `.comet.yml` config file in the home directory\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomet-ml%2Fcometr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomet-ml%2Fcometr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomet-ml%2Fcometr/lists"}