Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #19 from IBM/more-travis
Browse files Browse the repository at this point in the history
add flake8 to travis, too
  • Loading branch information
scottdangelo committed Sep 17, 2019
2 parents 3449dc9 + 468bb80 commit e11112b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 57 deletions.
22 changes: 14 additions & 8 deletions .travis.yml
@@ -1,8 +1,14 @@
language: node_js
node_js:
- 10
script:
- npm install
- gitbook install
- gitbook build
- npm test
matrix:
include:
- language: node_js
node_js: 10
script:
- npm install markdownlint-cli
- markdownlint --config .markdownlint.json workshop

- language: python
python: 3.7
script:
- pip install flake8
- pip install -r flaskapp/requirements.txt
- flake8 flaskapp/telcochurn.py --ignore=E501
49 changes: 27 additions & 22 deletions flaskapp/telcochurn.py
Expand Up @@ -39,7 +39,10 @@
"StreamingMovies": ['No', 'Yes', 'No internet service'],
"Contract": ['Month-to-month', 'One year', 'Two year'],
"PaperlessBilling": ['Yes', 'No'],
"PaymentMethod": ['Electronic check', 'Mailed check', 'Bank transfer (automatic)', 'Credit card (automatic)'],
"PaymentMethod": ['Electronic check',
'Mailed check',
'Bank transfer (automatic)',
'Credit card (automatic)'],
"Churn": ['No', 'Yes'],
}

Expand All @@ -51,44 +54,47 @@

# min, max, default value
ints = {
"SeniorCitizen" : [0, 1, 0],
"SeniorCitizen": [0, 1, 0],
"tenure": [0, 100, 2]
}


def generate_input_lines():
result = ""
for k in floats.keys():
minn, maxx, vall = floats[k]

result +=f'<dt>{k}</dt>'
result +=f'<dd>'
result +=f'$<input type="number" min="{minn}" max="{maxx}" step="0.01" name="{k}" id="{k}" value="{vall}" required onchange="show_value_{k}(this.value)">'
result +=f'</dd>'
result += f'<dt>{k}</dt>'
result += f'<dd>'
result += f'$<input type="number" min="{minn}" max="{maxx}" step="0.01" name="{k}" id="{k}" value="{vall}" required onchange="show_value_{k}(this.value)">'
result += f'</dd>'

for k in ints.keys():
minn, maxx, vall = ints[k]
result +=f'<dt>{k}</dt>'
result +=f'<dd>'
result +=f'<input type="number" min="{minn}" max="{maxx}" step="1" name="{k}" id="{k}" value="{vall}" required onchange="show_value_{k}(this.value)">'
result +=f'</dd>'

result += f'<dt>{k}</dt>'
result += f'<dd>'
result += f'<input type="number" min="{minn}" max="{maxx}" step="1" name="{k}" id="{k}" value="{vall}" required onchange="show_value_{k}(this.value)">'
result += f'</dd>'

for k in strings.keys():
result +=f'<dt>{k}</dt>'
result +=f'<dd>'
result += f'<dt>{k}</dt>'
result += f'<dd>'

if len("".join(strings[k])) < 10:
for value in strings[k]:
result +=f'<label><input type="radio" name="{k}" value="{value}" checked> {value} </label>'
result += f'<label><input type="radio" name="{k}" value="{value}" checked> {value} </label>'
else:
result +=f'<select name="{k}">'
result += f'<select name="{k}">'
for value in strings[k]:
result +=f'<option value="{value}" selected>{value}</option>'
result +=f'</select>'
result += f'<option value="{value}" selected>{value}</option>'
result += f'</select>'

result +=f'</dd>'
result += f'</dd>'

return result


app.jinja_env.globals.update(generate_input_lines=generate_input_lines)


Expand All @@ -101,11 +107,11 @@ def index():
ID = 999

session['ID'] = ID
data = {}
data = {}

for k, v in request.form.items():
data[k] = v
session[k] = v
data[k] = v
session[k] = v

scoring_href = os.environ.get('URL')
mltoken = os.environ.get('TOKEN')
Expand All @@ -130,8 +136,7 @@ def index():
result_json = json.loads(result)
churn_risk = result_json["result"]["predictions"][0].lower()
churn_risk = result_json["result"]["predictions"][0].lower()
flash(
'The risk of this customer churning is %s ' % churn_risk)
flash('The risk of this customer churning is %s ' % churn_risk)
return render_template(
'score.html',
result=result_json,
Expand Down
27 changes: 0 additions & 27 deletions package.json

This file was deleted.

0 comments on commit e11112b

Please sign in to comment.