Add alias to artifacts linked to a registered model/collection

I can update the aliases of an artifact that is not linked to a registered model in the following manner:

    api = wandb.Api()
    artifact = api.artifact('entity/project/artifact:v1')

    # Add an alias
    artifact.aliases.append('test')

    # Persist all artifact modifications
    artifact.save()

However, I cannot update an artifact linked to a registered model/collection.

    api = wandb.Api()
    artifact = api.artifact('entity/project/collection:v1')

    # Add an alias
    artifact.aliases.append('test')

    # Persist all artifact modifications
    artifact.save()

Error:

File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.wandb.ai/graphql

The only way to do it is by using the UI and manually adding an alias.
Is there a way to programmatically update the alias of an artifact in a collection/registered model?

Hi @ahmeds thank you for writing in, great to hear you’re using the model registry! The API to interact with the registered models is still in progress, and more features will be available in future releases. The current supported commands can be found in this reference doc and the companion Colab.

However, updating the aliases may be done by using the artifact and linking it back to the same. Please see below a code snippet:

import wandb
api = wandb.Api()
art = api.artifact('entity/project/artifact:v1', type='model')
art.link('entity/project/artifact', aliases=['test'])

Would this work for you?

Hi @ahmeds just checking in with you to see if you tried the above code and if it worked for you? thanks

Hi @ahmeds since we haven’t heard back from you, I will close this ticket for now. If you still experience this issue, please let us know and we will keep investigating!