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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ TZ=America/Montreal

# UDP port of the VPN server. If unset, 51820 is used
#VPN_SERVER_PORT=51820

# MTU limit (max should be 1420)
VPN_MTU=1280

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Vim
*~

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ docker compose down

To start from scratch, delete everything in `vpnserver_config/`, `researcher_vpn_config/` and `fbm-researcher/` except `.gitkeep` and `config.env.sample`.

### Troubleshooting

Run the script below to get the human-readable node name for every node that can connect to the researcher:

```bash
docker compose exec -u fedbiomed researcher python /brainflex-server/scripts/get_node_names.py
```

## Development

This project uses [uv](https://docs.astral.sh/uv/).
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
vpn-server:
container_name: brainflex-vpn-server-${FBM_CONTAINER_INSTANCE_ID:-default}
hostname: brainflex-vpn-server-${FBM_CONTAINER_INSTANCE_ID:-default}
image: ghcr.io/neurodatascience/brainflex-vpn-server:0.1.0@sha256:29e6463ae5696478913ff0c0973729c10af426f6507ecdb27f6c0be38038a1fd
image: ghcr.io/neurodatascience/brainflex-vpn-server:0.1.1@sha256:deb1ab2c842b6cd36afa7c2345928090b4172c453b50be30169b5c11957e5d84
cap_add:
- net_admin # needed to handle wireguard interface
devices:
Expand All @@ -38,7 +38,7 @@ services:
researcher-vpn:
container_name: brainflex-researcher-vpn-${FBM_CONTAINER_INSTANCE_ID:-default}
hostname: brainflex-researcher-${FBM_CONTAINER_INSTANCE_ID:-default}
image: ghcr.io/neurodatascience/brainflex-vpn-client:0.1.0@sha256:1c353258abde508771422e71384301aea88915b2f34bd2e236f3c8a9ab250de4
image: ghcr.io/neurodatascience/brainflex-vpn-client:0.1.1@sha256:e0696dda58501ca46954f4844842fd97e6b4476509fa0f835ad1f34107e34faf
cap_add:
- net_admin # needed to handle wireguard interface
devices:
Expand Down
31 changes: 31 additions & 0 deletions scripts/get_node_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

"""Print the node name and other identifying fields of every connected node."""

from fedbiomed.common.message import ListRequest
from fedbiomed.researcher.federated_workflows import Experiment


def main() -> None:
exp = Experiment() # no tags
message = ListRequest(researcher_id=exp.researcher_id)

with exp.requests.send(message) as federated_req:
replies = federated_req.replies()

if not replies:
print("No node replied")
return

for node_id, reply in replies.items():
fields = reply.get_dict() if hasattr(reply, "get_dict") else vars(reply)
print(f"\n=== {node_id} ===")
for key, value in fields.items():
if key == "databases":
print(f" {key}: {len(value)} dataset(s)")
else:
print(f" {key}: {value}")


if __name__ == "__main__":
main()
18 changes: 17 additions & 1 deletion scripts/request_training_plan_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"""Request the approval of the training plans by the nodes."""

import argparse
import faulthandler
import sys

from _tasks import COMMON_TAG, TASKS
from fedbiomed.common.constants import TrainingPlanApprovalStatus
from fedbiomed.common.logger import logger
from fedbiomed.researcher.federated_workflows import Experiment
from fedbiomed.researcher.federated_workflows.jobs import (
TrainingPlanApproveJob,
Expand All @@ -17,9 +19,14 @@
TRAINING_PLAN_NOT_REGISTERED = "Not Registered"
STATUS_SENT = "sent for approval"


def _get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument(
"--debug",
nargs="?",
const=-1,
help="Enable debug mode. Pass with an integer value n to exit after n seconds with a traceback.",
)
parser.add_argument(
"--task",
dest="tasks",
Expand Down Expand Up @@ -82,6 +89,15 @@ def _request_approval(task: str) -> dict[str, str]:

def main(argv: list[str] | None = None) -> None:
args = _get_parser().parse_args(argv)
if args.debug:
logger.setLevel("DEBUG")
try:
debug_seconds = int(args.debug)
except TypeError:
pass
else:
if debug_seconds > 0:
faulthandler.dump_traceback_later(debug_seconds, exit=True)
all_approved = True
for task in args.tasks or list(TASKS):
try:
Expand Down
Loading