Skip to content
Open
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
124 changes: 124 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

28 changes: 28 additions & 0 deletions library/foundaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json
import requests
from project_configuration import ProjectConfiguration
from project import Project

class FoundaMl:
def __init__(self, host, port, protocol='http'):
self.host = host
self.port = port
self.protocol = protocol

def getProject(self, projectId):
url = f'{self.protocol}://{self.host}:{self.port}/projects/{projectId}'
response = requests.get(url)
if response.status_code == 200:
responseData = json.loads(response.content )
projectId = responseData['id']
projectName = responseData['name']
projectProblem = responseData['problem']
projectAlgorithms = responseData['algorithms']
projectPolicy = responseData['policy']
projectFeaturesConfiguration = responseData['configuration']['features']
projectLabelsConfiguration = responseData['configuration']['labels']
projectConfiguration = ProjectConfiguration(projectFeaturesConfiguration, projectLabelsConfiguration)
project = Project(projectId, projectName, projectProblem, projectAlgorithms, projectPolicy, projectConfiguration)
return project
else:
return None
29 changes: 29 additions & 0 deletions library/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

class Project:
def __init__(self, projectId, name, problem, algorithms, policy, configuration):
self.projectId = projectId
self.name = name
self.problem = problem
self.algorithms = algorithms
self.policy = policy
self.configuration = configuration

def describe(self):
print(f"Name: {self.name}")
print(f"Problem: {self.problem} \n")
print("Features:")
for feature in self.configuration.features:
featureName = feature['name']
featureDescription = feature['description']
featureType = feature['type']
print(f"{featureName}|{featureType}|{featureDescription}")

print("")
labels = self.configuration.labels
labelType = labels['type']
if labelType == 'oneOf':
print("Labels:")
for labelName in labels['oneOf']:
print(labelName)
else:
print("Label: Dynamic")
6 changes: 6 additions & 0 deletions library/project_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

class ProjectConfiguration:

def __init__(self, features, labels):
self.features = features
self.labels = labels
5 changes: 5 additions & 0 deletions library/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
certifi==2019.3.9
chardet==3.0.4
idna==2.8
requests==2.21.0
urllib3==1.24.1
5 changes: 5 additions & 0 deletions samples/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from foundaml import FoundaMl

instance = FoundaMl('127.0.0.1', 8080)
project = instance.getProject('kaggle-titanic')
project.describe()