Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix uploading datasets #5

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ this file are optional and have default values.
[registry]
api_url = "https://anemoi.ecmwf.int/api/v1"

The second config file is ``~/.config/anemoi/settings.secrets.toml``. This
file must have the right permissions set to avoid unauthorized access
(`chmod 600 <filename>`). All keys in this file have no default values.
The second config file is ``~/.config/anemoi/settings.secrets.toml``.
This file must have the right permissions set to avoid unauthorized
access (`chmod 600 <filename>`). All keys in this file have no default
values.

.. code::

Expand Down
3 changes: 3 additions & 0 deletions src/anemoi/registry/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def post(self, path, data, errors={}):
def delete(self, path, errors={}):
if not config().get("allow_delete"):
raise ValueError("Unregister not allowed")
return self.unprotected_delete(path, errors=errors)

def unprotected_delete(self, path, errors={}):
r = self.session.delete(f"{config().api_url}/{path}", params=dict(force=True))
self.raise_for_status(r, errors=errors)
return r.json()
Expand Down
3 changes: 2 additions & 1 deletion src/anemoi/registry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ def set_status(self, status):
self.rest_item.patch(patch)

def unregister(self):
return self.rest_item.delete()
# deleting a task is unprotected because non-admin should be able to delete their tasks
return self.rest_item.unprotected_delete()

def take_ownership(self):
trace = trace_info()
Expand Down
Loading