Skip to content
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
5 changes: 4 additions & 1 deletion changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
## Changes

No changes.
- Support relative filesystem world paths in workspace configs.
- Default workspace configs emit relative filesystem world paths for project and session worlds.
- Filesystem world resolution expands `~` and resolves relative paths against the workspace root.
10 changes: 5 additions & 5 deletions donna/workspaces/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _default_sources() -> list[SourceConfig]:
]


def _create_default_worlds(project_dir: pathlib.Path) -> list[WorldConfig]:
def _create_default_worlds() -> list[WorldConfig]:
return [
WorldConfig.model_validate(
{
Expand All @@ -63,7 +63,7 @@ def _create_default_worlds(project_dir: pathlib.Path) -> list[WorldConfig]:
"kind": "donna.lib.worlds.filesystem",
"readonly": True,
"session": False,
"path": pathlib.Path.home() / DONNA_DIR_NAME / DONNA_WORLD_HOME_DIR_NAME,
"path": f"~/{DONNA_DIR_NAME}/{DONNA_WORLD_HOME_DIR_NAME}",
}
),
WorldConfig.model_validate(
Expand All @@ -72,7 +72,7 @@ def _create_default_worlds(project_dir: pathlib.Path) -> list[WorldConfig]:
"kind": "donna.lib.worlds.filesystem",
"readonly": False,
"session": False,
"path": project_dir / DONNA_DIR_NAME / DONNA_WORLD_PROJECT_DIR_NAME,
"path": pathlib.Path(DONNA_DIR_NAME) / DONNA_WORLD_PROJECT_DIR_NAME,
}
),
WorldConfig.model_validate(
Expand All @@ -81,14 +81,14 @@ def _create_default_worlds(project_dir: pathlib.Path) -> list[WorldConfig]:
"kind": "donna.lib.worlds.filesystem",
"readonly": False,
"session": True,
"path": project_dir / DONNA_DIR_NAME / DONNA_WORLD_SESSION_DIR_NAME,
"path": pathlib.Path(DONNA_DIR_NAME) / DONNA_WORLD_SESSION_DIR_NAME,
}
),
]


def _default_worlds() -> list[WorldConfig]:
return _create_default_worlds(project_dir())
return _create_default_worlds()


class Config(BaseEntity):
Expand Down
8 changes: 7 additions & 1 deletion donna/workspaces/worlds/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ def construct_world(self, config: "WorldConfig") -> World:
if path_value is None:
raise ValueError(f"World config '{config.id}' does not define a filesystem path")

from donna.workspaces.config import project_dir

path = pathlib.Path(path_value).expanduser()
if not path.is_absolute():
path = project_dir() / path

return World(
id=config.id,
path=pathlib.Path(path_value),
path=path.resolve(),
readonly=config.readonly,
session=config.session,
)