Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Final cleanup for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcorneliusmartin committed Apr 14, 2020
1 parent 150bdab commit ec5d723
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 29 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@

<img src="https://github.com/IKNL/guidelines/blob/master/resources/logos/vantage6.png?raw=true" width=200 align="right">
<img src="https://github.com/IKNL/guidelines/blob/master/resources/logos/vantage6.png?raw=true" width=180 align="right">

# Vantage6
> A federated learning solution
<!--
[![Coverage Status](https://coveralls.io/repos/github/IKNL/ppDLI/badge.svg?branch=master)](https://coveralls.io/github/IKNL/ppDLI?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bcde6ed5c77440c6969462bfead0774c)](https://app.codacy.com/app/frankcorneliusmartin/ppDLI?utm_source=github.com&utm_medium=referral&utm_content=IKNL/ppDLI&utm_campaign=Badge_Grade_Dashboard)
[![PyPI version](https://badge.fury.io/py/ppDLI.svg)](https://badge.fury.io/py/ppDLI)
[![Build Status](https://travis-ci.org/IKNL/ppDLI.svg?branch=master)](https://travis-ci.org/IKNL/ppDLI)
[![DOI](https://zenodo.org/badge/120275991.svg)](https://zenodo.org/badge/latestdoi/120275991)
-->
[![PyPI version](https://badge.fury.io/py/vantage6-common.svg)](https://badge.fury.io/py/vantage6-common)
This repository is part of the vantage6 solution. Vantage6 allowes to execute computations on federated datasets. This repository contains a common classes, methods, constants that are shared between the packages.

# Introduction
## :pray: Motivation
The growing complexity of cancer diagnosis and treatment requires data sets that are larger than currently available in a single hospital or even in cancer registries. However, sharing patient data is difficult due to patient privacy and data protection needs. Federated learning technology has the potential to overcome these limitations. In this approach, organizations can collaborate by exchanging aggregated data and/or statistics while keeping the underlying data safely on site and undisclosed. This repository contains software (and instructions) to setup a federated learning infrastructure.

For an overview of the architecture and information on how to use the infrastructure, please see [https://vantage6.ai](https://vantage6.ai). For documentation, please see [https://docs.distributedlearning.ai/](https://docs.distributedlearning.ai/).

## Installation
See the [documentation](https://docs.distributedlearning.ai/) for detailed instructions on how to install the server and nodes.

See the [documentation](https://docs.distributedlearning.ai/) for detailed instructions on how to install the server and nodes.
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
appdirs==1.4.3
certifi==2020.4.5.1
click==7.1.1
colorama==0.4.3
contextlib2==0.5.5
PyYAML==5.3.1
schema==0.7.1
termcolor==1.1.0
wincertstore==0.2
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@
description='Vantage6 common',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/IKNL/vantage6-client',
url='https://github.com/IKNL/vantage6-common',
packages=find_namespace_packages(),
python_requires='>=3.6',
install_requires=[
'appdirs==1.4.3',
'PyYAML==5.3.1',
'schema==0.7.1',
'termcolor==1.1.0',
'colorama==0.4.3',
'click==7.1.1',
'colorama==0.4.3'
'PyYAML==5.3.1'
],
package_data={
'vantage6': [
'vantage6.common': [
'common/VERSION'
],
}
)
)
2 changes: 2 additions & 0 deletions vantage6/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# init colorstuff
init()


def logger_name(special__name__):
log_name = special__name__.split('.')[-1]
if len(log_name) > 14:
Expand Down Expand Up @@ -58,5 +59,6 @@ def warning(msg):
def error(msg):
echo(msg, "error")


def debug(msg):
echo(msg, "debug")
6 changes: 4 additions & 2 deletions vantage6/common/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
# THE SOFTWARE.

import logging
import platform


class _AnsiColorStreamHandler(logging.StreamHandler):
DEFAULT = '\x1b[0m'
Expand Down Expand Up @@ -143,8 +145,8 @@ def emit(self, record):
self._set_color(self.FOREGROUND_WHITE)

# select ColorStreamHandler based on platform
import platform

if platform.system() == 'Windows':
ColorStreamHandler = _WinColorStreamHandler
else:
ColorStreamHandler = _AnsiColorStreamHandler
ColorStreamHandler = _AnsiColorStreamHandler
33 changes: 20 additions & 13 deletions vantage6/common/configuration_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path
from schema import Schema


class Configuration(collections.UserDict):
"""Base to contains a single configuration."""

Expand All @@ -16,7 +17,10 @@ def __setitem__(self, key, value):
""" Validation of a single item when put
"""
# assert key in self.VALIDATORS.keys(), "Invalid Key!"
schema = Schema(self.VALIDATORS.get(key,lambda x: True), ignore_extra_keys=True)
schema = Schema(
self.VALIDATORS.get(key, lambda x: True),
ignore_extra_keys=True
)
assert schema.is_valid(value), f"Invalid Value! {value} for {schema}"
super().__setitem__(key, value)

Expand All @@ -28,7 +32,8 @@ def __getitem__(self, key):

@property
def is_valid(self):
return Schema(self.VALIDATORS, ignore_extra_keys=True).is_valid(self.data)
schema = Schema(self.VALIDATORS, ignore_extra_keys=True)
return schema.is_valid(self.data)


class ConfigurationManager(object):
Expand Down Expand Up @@ -63,7 +68,7 @@ def __init__(self, conf_class=Configuration, name=None):
self.name = name
self.conf_class = conf_class

def put(self, env:str, config: dict):
def put(self, env: str, config: dict):
assert env in self.ENVS
configuration = self.conf_class(config)
# only set valid configs
Expand All @@ -73,19 +78,19 @@ def put(self, env:str, config: dict):
# print(f"config={config}")
# print(self.conf_class)

def get(self, env:str):
def get(self, env: str):
assert env in self.ENVS
return self.__getattribute__(env)

@property
def is_empty(self):
return not (self.application or self.prod or self.acc \
or self.test or self.dev)
return not (self.application or self.prod or self.acc
or self.test or self.dev)

@property
def environments(self):
return {"prod":self.prod, "acc":self.acc, "test":self.test,
"dev":self.dev, "application": self.application}
return {"prod": self.prod, "acc": self.acc, "test": self.test,
"dev": self.dev, "application": self.application}

@property
def has_application(self):
Expand All @@ -102,9 +107,9 @@ def available_environments(self):
def _get_environment_from_dict(self, d, e):
assert e in self.ENVS
if e == "application":
return d.get("application",{})
return d.get("application", {})
else:
return d.get("environments",{}).get(e,{})
return d.get("environments", {}).get(e, {})

def load(self, path):
with open(str(path), 'r') as f:
Expand All @@ -121,12 +126,14 @@ def from_file(cls, path, conf_class=Configuration):
conf.load(path)
return conf


def save(self, path):

config = {"application": dict(self.application), "environments": {
"prod": dict(self.prod), "acc": dict(self.acc), "test": dict(self.test),
"dev": dict(self.dev)}}
"prod": dict(self.prod),
"acc": dict(self.acc),
"test": dict(self.test),
"dev": dict(self.dev)}
}

Path(path).parent.mkdir(parents=True, exist_ok=True)
with open(path, 'w') as f:
Expand Down
2 changes: 1 addition & 1 deletion vantage6/common/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
PACAKAGE_FOLDER = Path(__file__).parent.parent.parent

with open(Path(PACAKAGE_FOLDER) / APPNAME / "common" / "VERSION") as f:
VERSION = f.read()
VERSION = f.read()
6 changes: 3 additions & 3 deletions vantage6/common/utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class TestRunner(unittest.TextTestRunner):

def __init__(self, log, stream=sys.stderr, descriptions=True, verbosity=1,
failfast=False, buffer=False, resultclass=None):
super(TestRunner, self).__init__(stream, descriptions, verbosity, failfast,
buffer, resultclass)
super(TestRunner, self).__init__(stream, descriptions, verbosity,
failfast, buffer, resultclass)
self.log = log

def _makeResult(self):
Expand All @@ -112,7 +112,7 @@ def find_tests(path=None):
# Find test cases
if path is None:
path = os.path.abspath(os.path.dirname(__file__))

loader = unittest.TestLoader()
suites = loader.discover(path)

Expand Down

0 comments on commit ec5d723

Please sign in to comment.