This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@trycatch expr | |
Convenience macro which wraps an expression in a `try/catch` block. | |
If the expression throws an error, it will be printed with the | |
`@error` macro. | |
# Examples | |
julia> @trycatch 1 + 1 | |
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using a python base image | |
FROM python:3.8 | |
# Set working directory to be /app | |
WORKDIR /app | |
# Copy flask app into the container | |
COPY app.py /app | |
# Install Flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello, world!" | |
if __name__ == "__main__": | |
app.run(debug=True,host="0.0.0.0",port=5000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
jupyter: | |
image: jupyter/datascience-notebook | |
ports: | |
- "8888:8888" | |
environment: | |
- JUPYTER_ENABLE_LAB=yes | |
volumes: | |
- .:/home/jovyan/work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@profile | |
def read_books(urls): | |
"""For each url in urls, | |
load the book and count the words""" | |
# Create a place to store word counts | |
word_counts = {} | |
# For each book: load it, count words, store the counts | |
for title, path in urls.items(): | |
book = get_book(path) | |
words = split_words(book) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Filename: script.py | |
Line # Mem usage Increment Line Contents | |
================================================ | |
19 38.426 MiB 38.426 MiB @profile | |
20 def read_books(urls): | |
21 """For each url in urls, | |
22 load the book and count the words""" | |
23 # Create a place to store word counts | |
24 38.426 MiB 0.000 MiB word_counts = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wrote profile results to script-profile.py.lprof | |
Timer unit: 1e-06 s | |
Total time: 5.62982 s | |
File: script-profile.py | |
Function: read_books at line 19 | |
Line # Hits Time Per Hit % Time Line Contents | |
======================================================== | |
19 @profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from collections import Counter | |
import urllib.request | |
def get_book(url): | |
"""Load text from a URL""" | |
with urllib.request.urlopen(url) as response: | |
text = response.read().decode(errors='ignore') | |
return text.lower() | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jinja2 | |
from IPython.display import display_svg | |
data = { | |
"title":"Time-Price Comparison", | |
"subtitle":"Scatter plot of time vs price.", | |
"data":[ | |
{"time":2,"price":1,"callout":False}, | |
{"time":3,"price":2,"callout":False}, | |
{"time":4,"price":3,"callout":True}, |
NewerOlder