Conda
conda: error: argument COMMAND: invalid choice: ‘activate’
Do conda init
first then restart the terminal and do conda activate xxx
again. But this will init conda everytime you start the shell by placing the related commands in your shell init scripts like bash_profile
. If we also have other package management systems like poetry
, venv
in use, we might not want to initialize conda all the time. We can instead activate conda explicitly:
conda env list
source /opt/homebrew/Caskroom/miniconda/base/bin/activate
/opt/homebrew/Caskroom/miniconda/base/envs/venv_name
instead of
conda activate venv_name
Use the actual paths for activate
and the virtual environment.
Alternatively, we can leave the conda initializaton scripts on, but use:
conda config --set auto_activate_base false
To make sure conda do not automatically invoke its base environment.
Configure lint
E501 stands for “line too long”. By default, PEP 8 recommends that lines should not exceed 79 characters.
[tool.autopep8]
ignore = [ "E501" ]
If using black
instead of autopep8
, you will need to it differently to disable it (not recommended)
[too.black]
line-length = 999 # very large number
When using black
together with isort
. We use
[tool.black]
line-length = 88
[tool.isort]
profile = "black"
to ensure that both isort
and Black
are using compatible rules, particularly regarding line length and import style.
Streamlit
Streamlit re-runs the entire script each time an input changes. To avoid unnecessarily re-run some one time statements, we can use the @st_cache decorator.
For example, we import from logging_config
from config.logging_config import get_logger
@st.cache_data()
def cached_get_logger(name):
return get_logger(name)
= cached_get_logger(__name__) logger
AWS concepts
Resources: S3 bucket, KMS key, EC2 instances Principals: users, services, or accounts Policies: permissions Roles: list of permissions User: persona associated with roles
Resource-based policies: specify who (the principal) has permission to access the rsources. Trust Policies (Relationships): specify which principlas are allowed to assume the role. User/Role-based policies: attach directly to users or roles (does not need the Principals here)