Skip to content

Commit

Permalink
Add weka option to DataSource (#280)
Browse files Browse the repository at this point in the history
* Add `weka` option to `DataSource`

* fix

* fix tests
  • Loading branch information
epwalsh authored Jun 14, 2024
1 parent df27ac8 commit 9dcabbc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use patch releases for compatibility fixes instead.

## Unreleased

### Added

- Added `weka` option to `DataSource` model.

### Fixed

- Only check for upgrades once every 12 hours by default.
Expand Down
8 changes: 8 additions & 0 deletions beaker/data_model/experiment_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ class DataSource(BaseModel, frozen=False):
- ``/var/beaker/share`` as a shared local scratch space.
"""

weka: Optional[str] = None
"""
The name of a weka bucket.
"""

result: Optional[str] = None
"""
Name of a previous task whose result will be mounted.
Expand Down Expand Up @@ -162,6 +167,7 @@ def new(
sub_path: Optional[str] = None,
beaker: Optional[str] = None,
host_path: Optional[str] = None,
weka: Optional[str] = None,
result: Optional[str] = None,
secret: Optional[str] = None,
) -> "DataMount":
Expand All @@ -172,6 +178,7 @@ def new(
:param sub_path: The :data:`sub_path`.
:param beaker: The :data:`beaker <DataSource.beaker>` argument to :class:`DataSource`.
:param host_path: The :data:`host_path <DataSource.host_path>` argument to :class:`DataSource`.
:param weka: The :data:`weka <DataSource.weka>` argument to :class:`DataSource`.
:param result: The :data:`result <DataSource.result>` argument to :class:`DataSource`.
:param url: The :data:`url <DataSource.url>` argument to :class:`DataSource`.
:param secret: The :data:`secret <DataSource.secret>` argument to :class:`DataSource`.
Expand All @@ -182,6 +189,7 @@ def new(
source=DataSource(
beaker=beaker,
host_path=host_path,
weka=weka,
result=result,
secret=secret,
),
Expand Down
3 changes: 3 additions & 0 deletions tests/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
from flaky import flaky

from beaker import Beaker
from beaker.config import InternalConfig


@flaky # this can fail if the request to GitHub fails
def test_warn_for_newer_version(monkeypatch):
import beaker.client
import beaker.version

InternalConfig().save()

monkeypatch.setattr(Beaker, "CLIENT_VERSION", "0.1.0")
monkeypatch.setattr(beaker.client, "_LATEST_VERSION_CHECKED", False)

Expand Down
10 changes: 8 additions & 2 deletions tests/data_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ def test_experiment_spec_validation():

def test_snake_case_vs_lower_camel_case():
for x in (DataSource(host_path="/tmp/foo"), DataSource(hostPath="/tmp/foo")): # type: ignore
assert str(x) == "DataSource(beaker=None, host_path='/tmp/foo', result=None, secret=None)"
assert (
str(x)
== "DataSource(beaker=None, host_path='/tmp/foo', weka=None, result=None, secret=None)"
)
assert x.host_path == "/tmp/foo"
x.host_path = "/tmp/bar"
assert str(x) == "DataSource(beaker=None, host_path='/tmp/bar', result=None, secret=None)"
assert (
str(x)
== "DataSource(beaker=None, host_path='/tmp/bar', weka=None, result=None, secret=None)"
)
assert x.to_json() == {"hostPath": "/tmp/bar"}


Expand Down

0 comments on commit 9dcabbc

Please sign in to comment.