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

Replace datalad-fuse with davfs2 #77

Merged
merged 2 commits into from
Jun 12, 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
5 changes: 3 additions & 2 deletions code/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ install_requires =
anyio ~= 4.0
async_generator ~= 1.10; python_version < '3.10'
click >= 8.0
datalad
datalad-fuse >= 0.5.1
ghreq ~= 0.1
hdmf
packaging
Expand All @@ -36,6 +34,9 @@ install_requires =
dandi =
# Needed for timing `dandi ls` runs
dandi
datalad-fuse =
datalad
datalad-fuse >= 0.5.1

[options.packages.find]
where = src
Expand Down
12 changes: 2 additions & 10 deletions code/src/healthstatus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .core import AssetPath, AssetTestResult, DandisetStatus, Outcome, TestSummary, log
from .mounts import (
AssetInDandiset,
FuseMounter,
DavFS2Mounter,
MountBenchmark,
MountType,
iter_mounters,
Expand Down Expand Up @@ -63,13 +63,6 @@ def main() -> None:


@main.command()
@click.option(
"-d",
"--dataset-path",
type=click.Path(file_okay=False, path_type=Path),
help="Directory containing a clone of dandi/dandisets",
required=True,
)
@click.option(
"-J",
"--dandiset-jobs",
Expand Down Expand Up @@ -100,7 +93,6 @@ def main() -> None:
)
@click.argument("dandisets", nargs=-1)
def check(
dataset_path: Path,
mount_point: Path,
dandiset_jobs: int,
dandisets: tuple[str, ...],
Expand All @@ -117,7 +109,7 @@ def check(
dandiset_jobs=dandiset_jobs,
versions=pkg_versions,
)
mnt = FuseMounter(dataset_path=dataset_path, mount_path=mount_point, update=True)
mnt = DavFS2Mounter(mount_path=mount_point)
with mnt.mount():
if mode == "all":
anyio.run(hs.run_all)
Expand Down
24 changes: 13 additions & 11 deletions code/src/healthstatus/mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
from signal import SIGINT
import subprocess
from time import sleep
from typing import Any
from typing import TYPE_CHECKING
import click
from datalad.api import Dataset
from ghreq import Client
from .core import AssetPath, log

if TYPE_CHECKING:
from datalad.api import Dataset

DANDIDAV_URL = "https://webdav.dandiarchive.org"


Expand Down Expand Up @@ -77,6 +79,8 @@

@contextmanager
def mount(self) -> Iterator[None]:
from datalad.api import Dataset

Check warning on line 82 in code/src/healthstatus/mounts.py

View check run for this annotation

Codecov / codecov/patch

code/src/healthstatus/mounts.py#L82

Added line #L82 was not covered by tests

if not self.dataset_path.exists():
log.info("Cloning dandi/dandisets to %s ...", self.dataset_path)
self.dataset_path.mkdir(parents=True, exist_ok=True)
Expand All @@ -91,7 +95,12 @@
)
get_dandisets(Dataset(self.dataset_path))
elif self.update:
update_dandisets(self.dataset_path)
log.info("Updating Dandisets dataset ...")
ds = Dataset(self.dataset_path)
ds.update(

Check warning on line 100 in code/src/healthstatus/mounts.py

View check run for this annotation

Codecov / codecov/patch

code/src/healthstatus/mounts.py#L99-L100

Added lines #L99 - L100 were not covered by tests
follow="parentds", how="ff-only", recursive=True, recursion_limit=1
)
get_dandisets(ds)

Check warning on line 103 in code/src/healthstatus/mounts.py

View check run for this annotation

Codecov / codecov/patch

code/src/healthstatus/mounts.py#L103

Added line #L103 was not covered by tests
self.mount_path.mkdir(parents=True, exist_ok=True)
with (self.logdir / "fuse.log").open("wb") as fp:
log.debug("Starting `datalad fusefs` process ...")
Expand Down Expand Up @@ -218,14 +227,7 @@
yield DavFS2Mounter(mount_path=mount_path)


def update_dandisets(dataset_path: Path) -> None:
log.info("Updating Dandisets dataset ...")
ds = Dataset(dataset_path)
ds.update(follow="parentds", how="ff-only", recursive=True, recursion_limit=1)
get_dandisets(ds)


def get_dandisets(ds: Any) -> None:
def get_dandisets(ds: Dataset) -> None:
# Fetch just the public repositories from the dandisets org, and then get
# or update just those subdatasets rather than trying to get all
# subdatasets and failing on private/embargoed ones
Expand Down
1 change: 1 addition & 0 deletions code/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ commands =
[testenv:typing]
deps =
mypy
datalad
# trio-typing contains the stubs for async_generator
trio-typing
types-pyyaml
Expand Down
3 changes: 1 addition & 2 deletions tools/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
set -ex

PYTHON="$HOME"/miniconda3/bin/python
DANDISETS_PATH=/mnt/backup/dandi/dandisets-healthstatus/dandisets
MOUNT_PATH=/mnt/backup/dandi/dandisets-healthstatus/dandisets-fuse

cd "$(dirname "$0")"/..
Expand All @@ -18,7 +17,7 @@ cd "$(dirname "$0")"/..
pip install ./code
#pip install 'git+https://github.com/fsspec/filesystem_spec'
#pip install 'git+https://github.com/jwodder/filesystem_spec@rlock-cache'
dandisets-healthstatus check -d "$DANDISETS_PATH" -m "$MOUNT_PATH" -J 10 "$@"
dandisets-healthstatus check -m "$MOUNT_PATH" -J 10 "$@"
dandisets-healthstatus report

# TODO: Uncomment this block when setting up the cronjob:
Expand Down