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

Add restart method to the data resource #349

Merged
merged 1 commit into from
Feb 22, 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
9 changes: 9 additions & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ Change Log
All notable changes to this project are documented in this file.


==========
Unreleased
==========

Added
-----
- Add ``restart`` method to the ``Data`` resource


===================
21.1.0 - 2023-02-09
===================
Expand Down
27 changes: 27 additions & 0 deletions src/resdk/resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import logging
from typing import Optional
from urllib.parse import urljoin

from resdk.constants import CHUNK_SIZE
Expand Down Expand Up @@ -223,6 +224,32 @@ def children(self):

return self._children

def restart(
self,
storage: Optional[int] = None,
memory: Optional[int] = None,
cores: Optional[int] = None,
):
"""Restart the data object.

The units for storage are gigabytes and for memory are megabytes.

The resources that are not specified (or set no None) are reset to their
default values.
"""
overrides = {
key: value
for key, value in {
"storage": storage,
"memory": memory,
"cores": cores,
}.items()
if value is not None
}
self.resolwe.api.data(self.id).restart.post(
{"resource_overrides": {self.id: overrides}}
)

def _files_dirs(self, field_type, file_name=None, field_name=None):
"""Get list of downloadable fields."""
download_list = []
Expand Down
Loading