Skip to content
Merged
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
56 changes: 56 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM ubuntu:22.04

ENV PYTHON_VERSION 3.12.1
ENV NODE_MAJOR 16
ENV DEBIAN_FRONTEND=noninteractive
#Set of all dependencies needed for pyenv to work on Ubuntu
RUN apt-get update \
&& apt-get install -y --no-install-recommends make build-essential libssl-dev libpq-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget ca-certificates curl gnupg llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8 git postgresql-client telnet unzip zlib1g-dev

RUN curl https://cli-assets.heroku.com/install.sh | sh
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get install nodejs -y

ARG USERNAME=cistudent
RUN useradd -ms /bin/bash $USERNAME
USER $USERNAME
WORKDIR /home/$USERNAME

# Set-up necessary Env vars for PyEnv
ENV PYENV_ROOT /home/$USERNAME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH

# Install pyenv
RUN set -ex \
&& curl https://pyenv.run | bash \
&& pyenv update \
&& pyenv install $PYTHON_VERSION \
&& pyenv global $PYTHON_VERSION \
&& pyenv rehash \
&& python3 -m pip install --no-cache-dir --upgrade pip \
&& python3 -m pip install --no-cache-dir --upgrade setuptools wheel virtualenv pipenv pylint rope flake8 mypy autopep8 pep8 pylama pydocstyle bandit notebook twine jupyter

ENV PATH=$PATH:"/home/cistudent/.local/bin"

RUN echo 'alias python=python3' >> ~/.bashrc && \
echo 'export PIP_USER=yes' >> ~/.bashrc && \
echo 'alias pip=pip3' >> ~/.bashrc && \
echo 'alias psql="psql mydb"' >> ~/.bashrc

COPY ./build-assets/heroku_config.sh /home/$USERNAME/.theia/heroku_config.sh
RUN echo 'alias heroku_config=". $HOME/.theia/heroku_config.sh"' >> ~/.bashrc

COPY ./build-assets/make_url.py /home/$USERNAME/.theia/make_url.py
RUN echo 'alias make_url="python3 $HOME/.theia/make_url.py "' >> ~/.bashrc

RUN mkdir -p /home/$USERNAME/.jupyter/custom
COPY ./build-assets/jupyter_notebook_config.py /home/$USERNAME/.jupyter/jupyter_notebook_config.py

COPY ./build-assets/custom.js /home/$USERNAME/.jupyter/custom/custom.js

USER root
RUN chown -R $USERNAME:$USERNAME /home/$USERNAME/.theia

CMD ["tail", "-f", "/dev/null"]
40 changes: 40 additions & 0 deletions .devcontainer/build-assets/heroku_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
# Script to allow Heroku API key to be pasted
# exported as an environment variable
#
# Matt Rudge, May 2021

echo Heroku authentication configuration script
echo Code Institute, 2021
echo
echo Get your Heroku API key by going to https://dashboard.heroku.com
echo Go to Account Settings and click on Reveal to view your Heroku API key
echo

if [[ -z "${HEROKU_API_KEY}" ]]; then
echo Paste your Heroku API key here or press Enter to quit:
read apikey
if [[ -z "${apikey}" ]]; then
return 0
fi
echo export HEROKU_API_KEY=${apikey} >> ~/.bashrc
echo Added the export. Refreshing the terminal.
. ~/.bashrc > /dev/null
echo Done!
else
echo API key is already set.
echo
echo To reset the API key please input "'reset'":
read reset_trigger
if [[ ${reset_trigger} == reset ]]; then
unset HEROKU_API_KEY
unset reset_trigger
echo
echo API key removed!
else
unset reset_trigger
echo API key unchanged.
fi
echo
echo Exiting
fi
14 changes: 14 additions & 0 deletions .devcontainer/build-assets/make_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Simple utility for creating the Cloudinary URL from a
# cloudinary_python.txt file
# Matt Rudge, November 2021

import re

with open("cloudinary_python.txt") as f:
content = f.readlines()

cloud_name = re.findall(r"['](.*?)[']", content[15])[0]
api_key = re.findall(r"['](.*?)[']", content[16])[0]
api_secret = re.findall(r"['](.*?)[']", content[17])[0]

print(f"cloudinary://{api_key}:{api_secret}@{cloud_name}")
112 changes: 112 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"name": "Codeinstitute template",
"dockerComposeFile": "docker-compose.yml",
"service": "app",


"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"formulahendry.auto-close-tag",
"eventyret.bootstrap-4-cdn-snippet",
"esbenp.prettier-vscode",
"matt-rudge.auto-open-preview-panel",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"bierner.markdown-preview-github-styles",
"gydunhn.vsc-essentials-core"

],
"settings": {
"files.exclude":{
"**/.git":true,
"**/.svn":true,
"**/.hg":true,
"**/CVS":true,
"**/.DS_Store":true,
"**/.github":true,
"**/.gitp*":true,
"**/.vscode":true,
"**/core.Microsoft*":true,
"**/core.mongo*":true,
"**/core.python*":true
},
"editor.defaultFormatter":"esbenp.prettier-vscode",
"python.linting.pycodestyleEnabled":true,
"python.terminal.activateEnvironment":false,
"workbench.iconTheme":"null",
"extensions.ignoreRecommendations":true,
"editor.tabCompletion":"on",
"editor.showDeprecated":true,
"editor.rulers":[
80
],
"editor.guides.bracketPairs":"active",
"editor.bracketPairColorization.independentColorPoolPerBracketType":true,
"workbench.tree.expandMode":"singleClick",
"workbench.tree.renderIndentGuides":"always",
"workbench.tree.indent":6,
"editor.formatOnType": false,
"editor.formatOnSave": false,
"editor.formatOnPaste": false,
"[markdown]":{
"editor.defaultFormatter":"bierner.markdown-preview-github-styles"
},
"[json]":{
"editor.defaultFormatter":"vscode.json-language-features"
},
"[jsonc]":{
"editor.defaultFormatter":"vscode.json-language-features"
},
"[xml]":{
"editor.defaultFormatter":"DotJoshJohnson.xml"
},
"[javascript]":{
"editor.defaultFormatter":"vscode.typescript-language-features"
},
"[typescript]":{
"editor.defaultFormatter":"vscode.typescript-language-features"
},
"[css]":{
"editor.defaultFormatter":"vscode.css-language-features"
},
"[less]":{
"editor.defaultFormatter":"vscode.css-language-features"
},
"[scss]":{
"editor.defaultFormatter":"vscode.css-language-features"
},
"[html]":{
"editor.defaultFormatter":"vscode.html-language-features"
},
"javascript.format.enable":true,
"javascript.format.semicolons":"insert",
"javascript.preferences.quoteStyle":"single",
"typescript.format.enable":true,
"typescript.format.semicolons":"insert",
"typescript.preferences.quoteStyle":"single",
"css.hover.documentation":true,
"css.lint.important":"warning",
"css.lint.importStatement":"warning",
"less.hover.documentation":true,
"less.lint.important":"warning",
"less.lint.importStatement":"warning",
"scss.hover.documentation":true,
"scss.lint.important":"warning",
"scss.lint.importStatement":"warning",
"html.hover.documentation":true,
"markdownlint.config":{
"default":true,
"MD001":false,
"MD010":false,
"MD024":false,
"MD025":false
}
}
}
},

"remoteUser": "cistudent"
}
4 changes: 4 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: '3'
services:
app:
image: public.ecr.aws/m5f1e7g7/ci-project-templates-predictive-analytics:version1.0
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__pycache__
*.ipynb
__pycache__
.venv/
40 changes: 0 additions & 40 deletions .gitpod.dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions .gitpod.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .vscode/init_tasks.sh

This file was deleted.

23 changes: 0 additions & 23 deletions .vscode/uptime.sh

This file was deleted.

8 changes: 4 additions & 4 deletions 1_commands_and_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@

#### Currently, every time you reload the dashboard page so is the script
#### this may cause a delay in your app, i.e.: you may reload multiple time the same data
#### to solve that, you can cache your data by adding a decorator @st.cache in a function that loads your data
#### to solve that, you can cache your data by adding a decorator @st.cache_data in a function that loads your data
#### in this example, you might not notice the speed difference, but in real applications, this difference is noticeable

# import numpy as np
# import pandas as pd

# @st.cache
# @st.cache_data
# def load_your_data():
# np.random.seed(1)
# df = pd.DataFrame(data={"Col1":np.random.randint(low=-100,high=100,size=10),
Expand Down Expand Up @@ -188,12 +188,12 @@


#### you can create 'columns' (or split the row space) and assign multiple items/widgets
#### you should use st.beta_columns() and inform amount of columns
#### you should use st.columns() and inform amount of columns
#### that will be assigned to individual variables, i.e.: if there were three columns, you would have col1, col2, col3
#### you will define the content on each variable with the command "with:"
#### this example prints a list in the first column and display a widget in the second column

# col1, col2 = st.beta_columns(2)
# col1, col2 = st.columns(2)
# with col1:
# st.write([1,2,3])
# with col2:
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

## How to use this repo

1. Fork this repo and copy the https URL of your forked streamlit-lesson repo
1. Fork this repo

1. Log into the cloud IDE with your GitHub account.
1. In your repo click on the green **Code** button.

1. On your Dashboard, click on the New Workspace button

1. Paste in the URL you copied from GitHub earlier

1. Click Create
1. Then, from the Codespaces tab, click **Create codespace on main**.

1. Wait for the workspace to open. This can take a few minutes.

Expand Down
Loading