Skip to content

Commit

Permalink
fix: pass settings to the jinja template. (#303)
Browse files Browse the repository at this point in the history
Because we did not implement a setter for the settings, command
line arguments were not passed to the jinja template.
Values were set, but .dict() used the _values dict which was
not updated by the setter.

Note that environment variables did work, so although
SOLARA_THEME_VARIANT=dark HOST=localhost solara run ...
Did work, the following did not:
HOST=localhost solara run ... --theme-variant=dark
  • Loading branch information
maartenbreddels authored and iisakkirotko committed Sep 29, 2023
1 parent 601bc38 commit 6cb7a82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions solara/minisettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def __get__(self, instance, owner):
return self
return instance._values[self.name]

def __set__(self, instance, value):
instance._values[self.name] = value


def convert(annotation, value: str) -> Any:
check_optional_types = [str, int, float, bool, Path]
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ def test_settings():
assert settings.value_no_field_other == 50
assert settings.path == Path("/tmp/test")
assert settings.path_optional == Path("/tmp/test/optional")


def test_dict():
settings = MySettings()
test_value = "some-other-value"
settings.value = test_value
assert settings.dict()["value"] == test_value

0 comments on commit 6cb7a82

Please sign in to comment.