Last active
July 25, 2022 15:58
-
-
Save cs224/d96a914cb254bee542b3417f0e139c2b to your computer and use it in GitHub Desktop.
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
# https://hub.docker.com/r/continuumio/miniconda3 | |
FROM continuumio/miniconda3:4.11.0 | |
LABEL maintainer="cs224 <cs224@weisser-zwerg.dev>" | |
USER root | |
RUN ln -s /bin/gzip /usr/bin/gzip | |
RUN ln -s /bin/tar /bin/gtar | |
# RUN groupadd -r mincond && useradd --no-log-init -r -g mincond mincond | |
# USER mincond | |
# WORKDIR /home/mincond | |
RUN conda install mamba -n base -c conda-forge | |
RUN mamba update -y conda --no-pin | |
RUN mamba install pip -n base | |
RUN pip install --upgrade pip | |
RUN conda init bash | |
COPY env-create-docker.sh $HOME/ | |
COPY environment.yml $HOME/ | |
COPY requirements.txt $HOME/ | |
RUN /bin/bash ./env-create-docker.sh | |
RUN echo "conda activate py38ds" >> ~/.bashrc |
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 py38ds-docker-base-image:latest | |
COPY cbja.py $HOME/ | |
COPY cas_automation.py $HOME/ | |
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "py38ds", "python3", "cas_automation.py", "-l", "-s", "-u"] |
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
#!/usr/bin/env bash | |
# exit when any command fails | |
set -e | |
echo ">> Setting-up py38ds environemnt" | |
mamba env create -f environment.yml | |
echo ">> Activating py38ds environment" | |
CONDA_BASE=$(conda info --base) | |
source ${CONDA_BASE}/etc/profile.d/conda.sh | |
conda activate py38ds | |
echo ">> Installing scs" | |
mamba install -c conda-forge scs | |
echo ">> Installing libgit2 and pystan from conda-forge" | |
mamba install -n py38ds -c conda-forge libgit2 jupyter_nbextensions_configurator | |
echo ">> Installing pip installable packages" | |
pip install -r requirements.txt | |
conda info --envs |
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
name: py38ds # drawdown investing | |
channels: | |
- numba | |
- defaults | |
dependencies: | |
- python=3.8 | |
- pip | |
- numpy | |
- numba | |
- scipy | |
- pandas | |
- matplotlib | |
- seaborn | |
- jupyter |
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
TAG_DATE=202112061151 | |
py38ds-docker-base-image: | |
docker build -f dockerfile.base --build-arg HTTP_PROXY=${HTTP_PROXY} --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg http_proxy=${HTTP_PROXY} --build-arg https_proxy=${HTTPS_PROXY} --tag py38ds-docker-base-image:${TAG_DATE} --tag py38ds-docker-base-image:latest . | |
# docker save -o py38ds-docker-base-image.tar py38ds-docker-base-image:latest | |
py38ds-container: | |
docker run -it --rm -v $(shell readlink -f .):/root/local:ro --name py38ds py38ds-docker-base-image:latest | |
py38ds-cas-image: | |
docker build -f dockerfile.cas --build-arg HTTP_PROXY=${HTTP_PROXY} --build-arg HTTPS_PROXY=${HTTPS_PROXY} --build-arg http_proxy=${HTTP_PROXY} --build-arg https_proxy=${HTTPS_PROXY} --tag py38ds-cas-image:${TAG_DATE} --tag py38ds-cas-image:latest . | |
py38ds-cas-container: | |
docker run -it --rm py38ds-cas-image:latest | |
# https://portal.azure.com/#blade/HubsExtension/BrowseResource/resourceType/Microsoft.ContainerRegistry%2Fregistries | |
# -> workableanalytics -> Quick start, Access keys | |
login: | |
docker login workableanalytics.azurecr.io | |
push: | |
docker tag workable-automation:${TAG_DATE} workableanalytics.azurecr.io/workableanalytics && docker push workableanalytics.azurecr.io/workableanalytics |
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
watermark | |
tqdm | |
requests | |
jinja2 | |
click |
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-Module Azure | |
Import-Module AzureRm.ContainerRegistry | |
Import-Module AzureRm.ContainerInstance | |
$connectionName = "AzureRunAsConnection" | |
try | |
{ | |
# Get the connection "AzureRunAsConnection " | |
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName | |
"Logging in to Azure..." | |
Add-AzureRmAccount ` | |
-ServicePrincipal ` | |
-TenantId $servicePrincipalConnection.TenantId ` | |
-ApplicationId $servicePrincipalConnection.ApplicationId ` | |
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | |
} | |
catch { | |
if (!$servicePrincipalConnection) | |
{ | |
$ErrorMessage = "Connection $connectionName not found." | |
throw $ErrorMessage | |
} else{ | |
Write-Error -Message $_.Exception | |
throw $_.Exception | |
} | |
} | |
"Successfully logged in to Azure..." | |
$cred = Get-AzureRmContainerRegistryCredential -ResourceGroupName "rg1" -Name "workableanalytics" | |
$secPassword = ConvertTo-SecureString $cred.Password -AsPlainText -Force | |
$acrCred = New-Object System.Management.Automation.PSCredential("workableanalytics", $secPassword) | |
New-AzureRmContainerGroup -ResourceGroupName rg1 -Name workable -Image workableanalytics.azurecr.io/workableanalytics -OsType Linux -RegistryCredential $acrCred -RestartPolicy Never -EnvironmentVariable @{"WORKABLE_BEARER_TOKEN"="val1";"SHAREPOINT_USER_NAME"="val2";"SHAREPOINT_USER_PASSWORD"="val3"} | |
Start-Sleep 120 | |
"inside loop.." | |
while($true) { | |
if ( (Get-AzureRmContainerInstanceLog -ResourceGroupName rg1 -ContainerGroupName workable) -eq "workable_automation finished running.`n") { | |
Remove-AzureRmContainerGroup -ResourceGroupName rg1 -Name workable | |
echo "Container removed" | |
Break | |
} | |
Start-Sleep 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment