- Best way is editable pip packages (reference)
pip install --editable /path/to/package
You need to include a minimal setup.py
from setuptools import setup, find_packages
setup(
pip install --editable /path/to/package
You need to include a minimal setup.py
from setuptools import setup, find_packages
setup(
### This gist gives you the code snippet to reach upper directories | |
### so you can reach other functions in the document | |
### e.g. from mainfolder.subfolder.subfolder.examplefile import example_function | |
#### Include upper dirs start | |
dpath = os.path.dirname(os.path.abspath(__file__)) | |
for i in range(4): | |
dpath = os.path.dirname(dpath) | |
sys.path.insert(1, dpath) | |
#### Include upper dirs end |
####### | |
### This is a minimal example of using HiGHS solver in R with the help of ROI and ompr packages. | |
####### | |
## SETUP BEGIN | |
pti <- c("ompr.roi","ompr","highs","devtools") | |
pti <- pti[!(pti %in% installed.packages())] | |
if(length(pti) > 0){ | |
install.packages(pti) | |
} |
import pandas as pd | |
def pd_reorder_cols(df, d): | |
""" | |
Reorders the position of columns with the given specs dictionary. | |
""" | |
cl = list(df.columns) | |
for k1, v1 in d.items(): | |
k1_ix = cl.index(k1) | |
cl.pop(k1_ix) |
--- | |
output: | |
html_fragment: | |
self_contained: false | |
always_allow_html: true | |
--- | |
```{=html} | |
<!DOCTYPE html> | |
``` |
from datatable import fread | |
import pandas as pd | |
excel_path = "my_excel_file.xlsx" | |
df = fread(excel_path+"/sheet_name").to_pandas() |
# This is an example docker run command to run streamlit which will include an ortools model | |
# -m 12g will keep the memory at 12GB | |
# --oom-kill-disable will prevent the container to go under because of out of memory sigkill | |
docker run -dp 80:8501 --oom-kill-disable -m 12g <image_name> |
FROM python:3.9.6 | |
RUN pip install --no-cache-dir streamlit | |
EXPOSE 8501 | |
ENTRYPOINT [ "streamlit" ] | |
CMD ["hello"] | |
## FOR ANY APPLICATION | |
ENTRYPOINT [ "streamlit", "run"] | |
CMD ["my_streamlit_file.py"] |
## Skip failing installations on requirements.txt | |
## https://stackoverflow.com/a/54053100/3608936 | |
cat requirements.txt | sed -e '/^\s*#.*$/d' -e '/^\s*$/d' | xargs -n 1 pip install | |
### Jupyter Notebook not working | |
## https://stackoverflow.com/a/59571314/3608936 | |
python3 -m notebook |
####### | |
#### This gist is a very quick way to implement just authentication function. This is a minimal example. | |
#### You need an AWS IAM account and your AWS Cognito User Pool set up. | |
#### Check the steps in the description of https://github.com/chi2labs/cognitoR | |
#### After creating your user pool on the left sidebar under General Settings, click on App clients | |
### Make sure "Enable username password based authentication (ALLOW_USER_PASSWORD_AUTH)" is checked | |
### Create a user from the interface for testing purposes. Let username be "usertest" and password be "passtest". | |
####### | |
#### Variables |