Skip to content

Commit

Permalink
Update experiment to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
alantrrs committed Jul 17, 2016
1 parent c47db3f commit 6345c6c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
9 changes: 0 additions & 9 deletions standalone_project/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# Start from a base image
FROM python:2.7-alpine

# Install empirical library
RUN apk add --update build-base wget

# TODO: These should be replaced by pip install empirical
RUN pip install zerorpc
RUN pip install requests

# Add files
COPY . /my-approach
WORKDIR /my-approach

RUN wget --no-check-certificate https://raw.githubusercontent.com/empiricalci/empirical.py/master/empirical.py

ENTRYPOINT ["python", "main.py"]
12 changes: 12 additions & 0 deletions standalone_project/dataset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"resources": {
"answers": {
"url": "https://raw.githubusercontent.com/empiricalci/fixtures/master/answers.csv",
"hash": "3d7219dab4803e82ad97ece9a49fc25c6fd3762a369236d131cb729f32946ff2"
},
"somedata": {
"url": "https://raw.githubusercontent.com/empiricalci/fixtures/master/data.csv",
"hash": "75821d9915567987edd0ff3271e276c922218c638e05efb2955a32c4526abdd9"
}
}
}
7 changes: 1 addition & 6 deletions standalone_project/empirical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@ experiments:
type: standalone
environment:
build: .
dataset:
resources:
- url: "https://raw.githubusercontent.com/empiricalci/fixtures/master/answers.csv"
hash: "3d7219dab4803e82ad97ece9a49fc25c6fd3762a369236d131cb729f32946ff2"
- url: "https://raw.githubusercontent.com/empiricalci/fixtures/master/data.csv"
hash: "75821d9915567987edd0ff3271e276c922218c638e05efb2955a32c4526abdd9"
dataset: dataset.json
16 changes: 4 additions & 12 deletions standalone_project/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import empirical
import csv

# Define and Instantiate Solver
Expand All @@ -22,32 +21,25 @@ def read_answers():

# Send problems to solvers
dataset = read_data()
print 'data:', dataset
solutions = []
for problem in dataset:
solutions.append(solver.solve(*problem))

# Evaluate solutions against ground truth
answers = read_answers()
print 'answers:', answers
correct_count = 0
for i in xrange(len(dataset)):
if solutions[i] == answers[i]:
correct_count = correct_count + 1

accuracy = correct_count / len(dataset)

# Save results
# Save overall
results = {
'overall': {
'type': 'table',
'metric': 'Accuracy',
'value': accuracy
}
'metric': 'Accuracy',
'value': accuracy
}
empirical.postResults(results)

# Also save them to the workspace
import json
with open('/workspace/output.json', 'w') as output:
with open('/workspace/overall.json', 'w') as output:
json.dump(results, output)

0 comments on commit 6345c6c

Please sign in to comment.