Skip to content

Commit

Permalink
Add restart method to the data resource
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorjerse committed Feb 22, 2024
1 parent 96c1f9c commit 4b85642
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
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

0 comments on commit 4b85642

Please sign in to comment.