Skip to content

Commit

Permalink
Merge pull request #36 from dandi/gh-35
Browse files Browse the repository at this point in the history
Use `reregisterurl` to move datalad remotes to web
  • Loading branch information
yarikoptic authored Jul 26, 2024
2 parents d53f154 + 125b6d3 commit 0d1e173
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Before running `backups2datalad`, the following setup must be performed:
required.

- [git-annex](https://git-annex.branchable.com) must be installed. At least
version 10.20240227 is required, though you should endeavor to obtain the
version 10.20240430 is required, though you should endeavor to obtain the
latest version.

- An API token needs to be obtained for the DANDI instance that is being
Expand Down
44 changes: 36 additions & 8 deletions src/backups2datalad/adataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Any, ClassVar

import anyio
from anyio.to_thread import run_sync
from dandi.consts import EmbargoStatus
from datalad.api import Dataset
from datalad.runner.exception import CommandError
Expand Down Expand Up @@ -161,14 +162,41 @@ async def ensure_dandi_provider(self, api_url: str) -> None:
)

async def disable_dandi_provider(self) -> None:
# See <https://github.com/dandi/backups2datalad/pull/21#issuecomment-1919164777>
# TODO: Once this is implemented, uncomment the commented-out portion
# of `test_backup_embargoed` in `test_commands.py`.
raise NotImplementedError(
"Waiting on Joey's input; see https://git-annex.branchable.com/"
"forum/how_to___34__move__34___URL_between_remotes__63__/"
)
await self.call_git("remote", "remove", "datalad") # type: ignore[unreachable]
# `anyio.run_process()` doesn't support files or streams as stdin to
# subprocesses, so we have to do this the synchronous way.

def reregister_keys() -> None:
with subprocess.Popen(
[
"git",
*GIT_OPTIONS,
"annex",
"find",
"--include=*",
"--format=${key}\\n",
],
cwd=self.pathobj,
stdout=subprocess.PIPE,
) as p:
try:
subprocess.run(
[
"git",
*GIT_OPTIONS,
"annex",
"reregisterurl",
"--batch",
"--move-from=datalad",
],
cwd=self.pathobj,
stdin=p.stdout,
check=True,
)
finally:
p.terminate()

await run_sync(reregister_keys)
await self.call_git("remote", "remove", "datalad")

async def is_dirty(self) -> bool:
return (
Expand Down
2 changes: 1 addition & 1 deletion src/backups2datalad/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

DEFAULT_WORKERS = 5

MINIMUM_GIT_ANNEX_VERSION = "10.20240227"
MINIMUM_GIT_ANNEX_VERSION = "10.20240430"

# Maximum number of Zarrs to process at once
ZARR_LIMIT = 10
Expand Down
5 changes: 0 additions & 5 deletions test/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,6 @@ async def test_backup_embargoed(
assert p.is_file()
assert p.read_text() == contents

# TODO: Awaiting resolution of
# https://github.com/dandi/backups2datalad/pull/21#issuecomment-1919164777;
# see `NotImplementedError` in `AsyncDataset.disable_dandi_provider()`
"""
await embargoed_dandiset.dandiset.unembargo()

r = await CliRunner().invoke(
Expand Down Expand Up @@ -411,4 +407,3 @@ async def test_backup_embargoed(
u.startswith(f"{docker_archive.s3endpoint}/{docker_archive.s3bucket}/")
for u in web_urls
)
"""

0 comments on commit 0d1e173

Please sign in to comment.