Handling a variable defined for a project

I am new to wandb so this might be a basic question,

I want to assign, modify and keep track of a variable assigned to a project. The use case would be let’s say I have a variable “count” assigned to a project staging with several workers collaborating on this project. Then lets say user A performs some runs offline and now wants to sync them to the project, then A would want to first retrieve the value of the “count” variable, assign it or tag it to all his runs and then sync them and finally increment “count” for the project. Now if user B wants to start his experiments he should be able to retrieve the current “count” value assign it to his set runs before syncing them, I would really appreciate any help on what would be the best way to achieve this.

Hi @prishruit thanks for writing in! This is an interesting use case, we have a feature request on having Tags or metadata at the project level which would help but it’s not currently available.

A workaround to mock this functionality would be to log this variable count as an Artifact. This could be either a wandb.Table if you were interested to have some version control enabled, or a simpler option would be to include that information as key:value in a dummy artifact’s metadata. Please see below an example of this:

The first run (online) will log the dummy artifact as follows:

art = wandb.Artifact(name='project-tags', type='metadata', metadata={'count': 1})

Before running the next offline runs, you can get the count value from API as:

api = wandb.Api()
art = api.artifact('ENTITY/artifact-project/project-tags:latest', type='metadata')
count = art.metadata['count']

Then you could update the artifact metadata any time you would need either from a run as below or from API (with artifact.save() method):

art = wandb.use_artifact('ENTITY/artifact-project/project-tags:latest', type='metadata')
art.metadata['count'] = 2

Would this work for your use case? Please note in this simpler version it won’t create any new artifact versions, and if you wanted to also track its lineage you might want to write the value to a wandb.Table.

Hi @prishruit I wanted to follow up with you on this request. I was wondering if you’ve tried the above, would this work for you and are there any more questions we could help with? thanks!

Hi @prishruit since we haven’t heard back from you, I will go ahead and close this ticket for now. However, please let us know if you’re still having any issues or further questions, and we will be happy to assist you further.