diff --git a/.github/workflows/auth-ci.yml b/.github/workflows/auth-ci.yml index b41b695bc..68439cd6c 100644 --- a/.github/workflows/auth-ci.yml +++ b/.github/workflows/auth-ci.yml @@ -37,7 +37,7 @@ jobs: working-directory: . run: | python -m pip install --upgrade pip - pip install -e cli/ + pip install ./cli pip install -r cli/test-requirements.txt pip install -r server/requirements.txt pip install -r server/test-requirements.txt @@ -48,7 +48,7 @@ jobs: - name: Run django server in background with generated certs working-directory: ./server - run: sh setup-dev-server.sh & sleep 6 + run: sh setup-dev-server.sh -c cert.crt -k cert.key & sleep 6 - name: Run server integration tests working-directory: ./server diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index b7d778782..061573982 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -38,7 +38,7 @@ jobs: working-directory: . run: | python -m pip install --upgrade pip - pip install -e cli/ + pip install cli/ pip install -r cli/test-requirements.txt pip install -r server/requirements.txt pip install -r server/test-requirements.txt @@ -57,6 +57,12 @@ jobs: cp ../mock_tokens/tokens.json tokens.json docker build -t ${{ env.IMAGE_NAME }} -f Dockerfile.gha . + - name: Copy configurations for MedPerf client + working-directory: ./server + run: | + cp tokens.json ~/.medperf_dev/tokens.json + cp cert.crt ~/.medperf_dev/cert.crt + - name: Run server in background working-directory: ./server run: PORT=8080 && docker run --name medperf_api -d -p 8000:${PORT} -e PORT=${PORT} -e SSL_FLAGS="--certfile=cert.crt --keyfile=cert.key" ${{ env.IMAGE_NAME }} diff --git a/.github/workflows/local-ci.yml b/.github/workflows/local-ci.yml index 10fcb2550..16ec68d2e 100644 --- a/.github/workflows/local-ci.yml +++ b/.github/workflows/local-ci.yml @@ -38,7 +38,7 @@ jobs: working-directory: . run: | python -m pip install --upgrade pip - pip install -e cli/ + pip install cli/ pip install -r cli/test-requirements.txt pip install -r server/requirements.txt pip install -r server/test-requirements.txt @@ -53,7 +53,7 @@ jobs: - name: Run server integration tests working-directory: ./server - run: python seed.py --cert cert.crt + run: python seed.py - name: Run chestxray demo working-directory: . diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 11c570b73..904a0657b 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -21,7 +21,7 @@ jobs: python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f cli/requirements.txt ]; then pip install -e cli; fi + if [ -f cli/requirements.txt ]; then pip install ./cli; fi pip install -r server/requirements.txt pip install -r server/test-requirements.txt - name: Lint with flake8 diff --git a/cli/medperf/commands/__init__.py b/cli/medperf/commands/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/association/__init__.py b/cli/medperf/commands/association/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/auth/__init__.py b/cli/medperf/commands/auth/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/benchmark/__init__.py b/cli/medperf/commands/benchmark/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/compatibility_test/__init__.py b/cli/medperf/commands/compatibility_test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/dataset/__init__.py b/cli/medperf/commands/dataset/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/mlcube/__init__.py b/cli/medperf/commands/mlcube/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/commands/result/__init__.py b/cli/medperf/commands/result/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/comms/__init__.py b/cli/medperf/comms/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/config.py b/cli/medperf/config.py index 98506bb65..681029d3e 100644 --- a/cli/medperf/config.py +++ b/cli/medperf/config.py @@ -1,8 +1,6 @@ from ._version import __version__ from pathlib import Path -BASE_DIR = Path(__file__).resolve().parent.parent.parent - major_version, minor_version, patch_version = __version__.split(".") # MedPerf server @@ -10,7 +8,6 @@ certificate = None local_server = "https://localhost:8000" -local_certificate = str(BASE_DIR / "server" / "cert.crt") comms = "REST" @@ -39,8 +36,6 @@ access_token_storage_id = "medperf_access_token" refresh_token_storage_id = "medperf_refresh_token" -local_tokens_path = BASE_DIR / "mock_tokens" / "tokens.json" - # Storage config config_storage = Path.home().resolve() / ".medperf_config" logs_storage = Path.home().resolve() / ".medperf_logs" @@ -49,6 +44,10 @@ creds_folder = str(config_storage / ".tokens") tokens_db = str(config_storage / ".tokens_db") +local_server_config_storage = Path.home().resolve() / ".medperf_dev" +local_tokens_path = local_server_config_storage / "tokens.json" +local_certificate = str(local_server_config_storage / "cert.crt") + images_folder = ".images" trash_folder = ".trash" tmp_folder = ".tmp" diff --git a/cli/medperf/entities/__init__.py b/cli/medperf/entities/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/tests/commands/auth/__init__.py b/cli/medperf/tests/commands/auth/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/tests/comms/__init__.py b/cli/medperf/tests/comms/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/tests/comms/entity_resources/__init__.py b/cli/medperf/tests/comms/entity_resources/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/tests/comms/entity_resources/sources/__init__.py b/cli/medperf/tests/comms/entity_resources/sources/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/tests/entities/__init__.py b/cli/medperf/tests/entities/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/tests/ui/__init__.py b/cli/medperf/tests/ui/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/ui/__init__.py b/cli/medperf/ui/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/cli/medperf/utils.py b/cli/medperf/utils.py index 35aa697d6..21a627aaf 100644 --- a/cli/medperf/utils.py +++ b/cli/medperf/utils.py @@ -19,7 +19,7 @@ from typing import List from colorama import Fore, Style from pexpect.exceptions import TIMEOUT -from git import Repo, GitCommandError +from git import Repo, GitCommandError, InvalidGitRepositoryError import medperf.config as config from medperf.exceptions import ExecutionError, MedperfException @@ -430,7 +430,12 @@ def filter_latest_associations(associations, entity_key): def check_for_updates() -> None: """Check if the current branch is up-to-date with its remote counterpart using GitPython.""" - repo = Repo(config.BASE_DIR) + repo_root_dir = Path(__file__).resolve().parent.parent.parent + try: + repo = Repo(repo_root_dir) + except InvalidGitRepositoryError: # package is installed not in -e mode from git repo + return + if repo.bare: logging.debug("Repo is bare") return diff --git a/cli/setup.py b/cli/setup.py index bd4362d15..74e239b5f 100644 --- a/cli/setup.py +++ b/cli/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup +from setuptools import setup, find_packages from medperf._version import __version__ with open("requirements.txt", "r") as f: @@ -15,10 +15,12 @@ name="medperf", version=__version__, description="CLI Tool for federated benchmarking on medical private data", - url="https://github.com/aristizabal95/medperf", + long_description=open('../README.md').read(), + long_description_content_type='text/markdown', + url="https://github.com/mlcommons/medperf", author="MLCommons", license="Apache 2.0", - packages=["medperf"], + packages=find_packages(where="."), install_requires=requires, python_requires=">=3.6", entry_points=""" diff --git a/docs/getting_started/installation.md b/docs/getting_started/installation.md index ee54f8e98..0d857b6d7 100644 --- a/docs/getting_started/installation.md +++ b/docs/getting_started/installation.md @@ -62,7 +62,7 @@ If using Docker, make sure [you can run Docker as a non-root user.](https://docs 3. Install MedPerf from source: ```bash - pip install -e ./cli + pip install ./cli ``` 4. Verify the installation: diff --git a/docs/mlcubes/shared/build.md b/docs/mlcubes/shared/build.md index 33a3c18cf..9fccaf311 100644 --- a/docs/mlcubes/shared/build.md +++ b/docs/mlcubes/shared/build.md @@ -13,7 +13,7 @@ MedPerf provides some cookiecutter templates for all the related MLCubes. Additi 2. Install the MedPerf CLI: ```bash - pip install -e cli + pip install ./cli ``` 3. If you have not done so, create a folder for keeping all MLCubes created in this tutorial: diff --git a/server/seed.py b/server/seed.py index be4d387f4..8fb2ba7ed 100644 --- a/server/seed.py +++ b/server/seed.py @@ -11,8 +11,10 @@ from seed_utils import Server, set_user_as_admin, create_benchmark, create_model from auth_provider_token import auth_provider_token from pathlib import Path +import shutil import json +DEV_CONFIG_DIR = Path.home() / ".medperf_dev" REPO_BASE_DIR = Path(__file__).resolve().parent.parent @@ -46,8 +48,9 @@ def seed(args): if __name__ == "__main__": - default_cert_file = str(REPO_BASE_DIR / "server" / "cert.crt") - default_tokens_file = str(REPO_BASE_DIR / "mock_tokens" / "tokens.json") + default_cert_file = str(DEV_CONFIG_DIR / "cert.crt") + local_tokens_file = str(REPO_BASE_DIR / "mock_tokens" / "tokens.json") + dest_tokens_file = str(DEV_CONFIG_DIR / "tokens.json") parser = argparse.ArgumentParser(description="Seed the db with demo entries") parser.add_argument( @@ -78,9 +81,13 @@ def seed(args): "--tokens", type=str, help="Path to local tokens file", - default=default_tokens_file, + default=local_tokens_file, ) args = parser.parse_args() if args.cert.lower() == "none": args.cert = None + DEV_CONFIG_DIR.mkdir(parents=True, exist_ok=True) + print('config folder:', DEV_CONFIG_DIR, DEV_CONFIG_DIR.exists()) + shutil.copy(args.tokens, dest_tokens_file) # for usage by medperf client + print('token file:', dest_tokens_file, Path(dest_tokens_file).exists()) seed(args) diff --git a/server/setup-dev-server.sh b/server/setup-dev-server.sh index 4d0599f6d..fe950cd7e 100644 --- a/server/setup-dev-server.sh +++ b/server/setup-dev-server.sh @@ -9,19 +9,21 @@ do esac done +CONFIG_PATH=$HOME/.medperf_dev DEPLOY="${DEPLOY:-1}" CERT_GENERATE="${CERT_GENERATE:-1}" -CERT_FILE="${CERT_FILE:-cert.crt}" -KEY_FILE="${KEY_FILE:-cert.key}" +CERT_FILE="${CERT_FILE:-$CONFIG_PATH/cert.crt}" +KEY_FILE="${KEY_FILE:-$CONFIG_PATH/cert.key}" RESET_DB="${RESET_DB:-0}" echo $CERT_FILE echo $KEY_FILE echo $DEPLOY echo $CERT_GENERATE -echo $CERT_PATH echo $RESET_DB +echo $CONFIG_PATH +mkdir -p $CONFIG_PATH if [ -z "$CERT_FILE" ] then