diff --git a/.gitignore b/.gitignore index ea4b5423fc44e409b96c6051207fa6ba96009f6d..08aaa8ee46cef6362c9395208a3ab9ba1f2b3f48 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ # build and conda-build artifacts build/* +conda-bld/* dist/* *.egg-info/* \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d33521af10bcc7fd8cea344038eaaeb78d0ef5..0000000000000000000000000000000000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2d6447d11dfe32bfb846c3d5b199fc99..0000000000000000000000000000000000000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ -<component name="InspectionProjectProfileManager"> - <settings> - <option name="USE_PROJECT_PROFILE" value="false" /> - <version value="1.0" /> - </settings> -</component> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 1a4d1ba605abd69ba93129b21071e29168076cdb..0000000000000000000000000000000000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (model_server_env)" project-jdk-type="Python SDK" /> -</project> \ No newline at end of file diff --git a/.idea/model_server.iml b/.idea/model_server.iml deleted file mode 100644 index 57c52987a7d5da8ba7e7a5c64de0344a03c7099c..0000000000000000000000000000000000000000 --- a/.idea/model_server.iml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="PYTHON_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/model_server" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="false" /> - </content> - <orderEntry type="jdk" jdkName="Python 3.9 (model_server_env)" jdkType="Python SDK" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 1f65a314e4138ce057f347daca726d72621cf5d4..0000000000000000000000000000000000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/model_server.iml" filepath="$PROJECT_DIR$/.idea/model_server.iml" /> - </modules> - </component> -</project> \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f4cb416c083d265558da75d457237d671..0000000000000000000000000000000000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$" vcs="Git" /> - </component> -</project> \ No newline at end of file diff --git a/README.md b/README.md index 4770aa9a3ec6db3266d73486189e1887b69a0e50..2acdf5e372fc7f97223ab6004992aec8e9d9b5b9 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,29 @@ model_server is a service for on-demand computer vision, adapted specifically to and other life sciences applications. It abstracts image data access, persists machine learning models, and exposes an extensible API to facilitate low-latency analysis. -## Installation from source: +## Install Git and miniforge +1. Install Miniforge for environment management:<br>https://github.com/conda-forge/miniforge/releases +2. Under the Start menu, open `Miniforge3 > Miniforge Prompt` +## Option 1: install model_server as a package: +1. Download the most recent version of the built package from:<br>https://git.embl.de/rhodes/model_server/-/packages/1280 +2. (optional) activate the target conda environment: `mamba activate <target_environment>` +3. From the package repository https://git.embl.de/rhodes/model_server/-/packages/ download: + - The most recent requirements.yml + - The most recent .tar.bz2 file containing the built conda package +4. In a text editor, open requirements.yml and remove all but the "channels" and "dependencies" blocks, then save. +5. Change directories to the location of 'requirements.yml' and install dependencies:<br>`mamba env update -f requirements.yml` +6. Download the most recent .tar.bz2 file containing the built conda package from:<br>https://git.embl.de/rhodes/model_server/-/packages/1283 +7. Change directories to the downloaded file and install model_server package: `mamba install model_server-<version>-py_0.tar.bz2` + +## Option 2: install model_server from source: 1. Install Git:<br>https://git-scm.com/download/win -2. Install Miniforge for environment management:<br>https://github.com/conda-forge/miniforge/releases -3. Under the Start menu, open `Miniforge3 > Miniforge Prompt` -4. In the new terminal, clone the model_server repository:<br> - `cd %userprofile%`<br> - `git clone https://almf-staff:KJmFvyPRbpzoVZDqfMzV@git.embl.de/rhodes/model_server.git` -5. Create the environment: `mamba env create --file requirements.yml --name model_server_env` -6. Activate the environment: `mamba activate model_server_env` -7. Add the project source as a Python package: `pip install --no-deps -e .` +2. In the new terminal, clone the model_server repository:<br>`cd %userprofile%`<br>`git clone https://almf-staff:KJmFvyPRbpzoVZDqfMzV@git.embl.de/rhodes/model_server.git` +3. Create the target environment: `mamba env create --file requirements.yml --name model_server_env` +4. Activate the target environment: `mamba activate model_server_env` +5. Add the project source as a Python package: `pip install --no-deps -e .` ## To start the server: -1. From the Miniforge prompt, run `mamba activate model_server_env` +1. From the Miniforge prompt, run `mamba activate <target_environment>` 2. Then run `python -m scripts.run_server --port 6221` 3. A browser window should appear, with basic status information. diff --git a/conda-recipe/publish.py b/conda-recipe/publish.py new file mode 100644 index 0000000000000000000000000000000000000000..071d9a5f52e6950848653e4d78e010eea65993b4 --- /dev/null +++ b/conda-recipe/publish.py @@ -0,0 +1,51 @@ +""" +Automate registration of conda build artifacts to EMBL GitLab; +assumes API access token is recorded in ~/.pypirc shell configuration file +""" +from configparser import ConfigParser +import json +from pathlib import Path +import requests + +id = '5668' +proj = 'model_server' +root = Path('../conda-bld/') + +# get authentication info from local config file +cfg = ConfigParser() +cfg.read(Path.home() / '.pypirc') +user = cfg['gitlab-model-server']['username'] +pwd = cfg['gitlab-model-server']['password'] + +with open(root / 'channeldata.json', 'r') as fh: + chdata = json.load(fh) + +# upload to GitLab API +res = {} +for sd in ['noarch', 'win-64']: + with open(root / sd / 'repodata.json', 'r') as fh: + dd = json.load(fh) + pkgname = f'conda_{sd}' + + if len(dd['packages']) == 0: + continue + + # put each .tar.bz2 + for fn in dd['packages'].keys(): + ver = dd['packages'][fn]['version'] + stem = fn.split('.tar.bz2')[0] + res[(sd, fn)] = requests.put( + f'https://git.embl.de/api/v4/projects/{id}/packages/generic/{pkgname}/{ver}/{fn}?status=default', + files={'file': open(root / sd / fn, 'rb')}, + headers={'PRIVATE-TOKEN': pwd}, + ) + + # put requirements.yml + fn = 'requirements.yml' + res[(sd, fn)] = requests.put( + f'https://git.embl.de/api/v4/projects/{id}/packages/generic/{pkgname}/{ver}/{fn}?status=default', + files={'file': open(root.parent / fn, 'r')}, + headers={'PRIVATE-TOKEN': pwd, 'Content-Type': 'text/html'}, + ) +print('Finished') +print(res) \ No newline at end of file diff --git a/requirements.yml b/requirements.yml index 0953d35351133ebf340d2dc3fb25719c4bfbac82..fa5b53ab6818d693eeb428cc3008de839412a8c1 100644 --- a/requirements.yml +++ b/requirements.yml @@ -1,4 +1,4 @@ -name: model_server_mqtt +name: model_server channels: - pytorch - ilastik-forge