Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b13c8ef

Browse files
committedMar 12, 2024
init repo
0 parents  commit b13c8ef

13 files changed

+415
-0
lines changed
 

‎.devcontainer/Dockerfile.debug

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Comments are provided throughout this file to help you get started.
2+
# If you need more help, visit the Dockerfile reference guide at https://docs.docker.com/go/dockerfile-reference/
3+
4+
# Create a docker conda image
5+
# Offical Available Dev Container Templates, see https://containers.dev/templates
6+
# NOTE: Non Dev Container *Conda Installations might lead to errors during building the container.
7+
FROM mcr.microsoft.com/devcontainers/miniconda
8+
9+
USER root
10+
11+
# Copy the environment.yml file to the container. Also
12+
# copy "noop.txt" so the COPY instruction does not fail if no environment.yml exists.
13+
COPY environment.yml* noop.txt /requirements/
14+
15+
16+
# Make RUN commands use `bash --login`:
17+
# SHELL ["/bin/bash", "--login", "-c"]
18+
19+
# Install linux packages
20+
RUN apt-get update
21+
# Install git, process tools
22+
RUN apt-get update && apt-get -y install git procps build-essential curl swig
23+
# RUN apt-get update && \
24+
# apt-get upgrade -y && \
25+
# apt-get install -y git
26+
RUN git config --global --add safe.directory /workspace
27+
28+
# Add the conda directory to your Linux PATH, since this is not done automatically after installation.
29+
RUN conda init bash
30+
31+
# Update conda, install and set libmamba solver
32+
RUN conda update -n base conda -y
33+
RUN conda install -n base conda-libmamba-solver
34+
RUN conda config --set solver libmamba
35+
36+
# Create conda env (for your data science work)
37+
RUN conda env create --file requirements/environment.yml
38+
39+
RUN conda install ipython_genutils
40+
RUN conda install ipykernel
41+
RUN ipython kernel install --user --name=env1
42+
43+
44+
# RUN conda init
45+
46+
# TODO: switch from mcr.microsoft.com/devcontainers/miniconda to conda/miniconda3:latest
47+
# Install Git, since not available in conda/miniconda3:latest
48+
# RUN apt-get update && \
49+
# apt-get upgrade -y && \
50+
# apt-get install -y git
51+
# RUN git config --global --add safe.directory /workspace
52+
53+
54+
# The code to run when container is started:
55+
# Common practice to keep the Docker container running without performing any significant action.
56+
ENTRYPOINT ["tail", "-f", "/dev/null"]

‎.devcontainer/devcontainer.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/anaconda
3+
{
4+
"name": "dat.dev-container-conda",
5+
"dockerComposeFile": ["./docker-compose.yml"],
6+
"service": "project",
7+
"runServices": ["project"],
8+
"workspaceFolder": "/workspace",
9+
// Avoid dubious ownership in repository in dev container,
10+
// see https://github.com/microsoft/vscode-remote-release/issues/6810 or https://www.kenmuse.com/blog/avoiding-dubious-ownership-in-dev-containers/
11+
"postCreateCommand": {
12+
// "git": "sudo apt-get update && sudo apt-get install -y git",
13+
"git": "git config --global --add safe.directory /workspace",
14+
"conda_init": "conda init"
15+
// "conda_activate": "conda activate env1"
16+
},
17+
// "postStartCommand": {
18+
// // "git": "sudo apt-get update && sudo apt-get install -y git",
19+
// // "git": "git config --global --add safe.directory /workspace",
20+
// // "conda_init": "conda init"
21+
// "conda_activate": "conda activate env1"
22+
// },
23+
"customizations": {
24+
// When connecting to a docker container your local VS Code starts an instance without extensions to ensure isolation and consitency.
25+
// Therefore extensions can be specified here for automatic installation when connecting.
26+
"vscode": {
27+
"settings": {
28+
"terminal.integrated.profiles.linux": {
29+
"bash": {
30+
"path": "/bin/bash"
31+
}
32+
}
33+
},
34+
// Use the VS Code Extenstions "Identifier" to define extensions
35+
"extensions": [
36+
"ms-python.python",
37+
"ms-python.vscode-pylance",
38+
"ms-python.black-formatter",
39+
"ms-azuretools.vscode-docker",
40+
"ms-toolsai.jupyter"
41+
//"zainchen.json",
42+
//"tomoki1207.pdf",
43+
//"grapecity.gc-excelviewer"
44+
]
45+
}
46+
}
47+
}

‎.devcontainer/docker-compose.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# version: "3.7"
2+
3+
# networks:
4+
# app-net: null
5+
6+
services:
7+
project:
8+
# tells Docker Compose to build the Docker image using the Dockerfile in the specified directory.
9+
build:
10+
context: .
11+
dockerfile: ./Dockerfile.debug
12+
image: dat/dev-container-conda
13+
# networks:
14+
# - app-net
15+
16+
# Map local volume (parent dir) to container (/workspace)
17+
volumes:
18+
- ../:/workspace

‎.devcontainer/environment.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: env1
2+
3+
channels:
4+
- conda-forge
5+
- pytorch
6+
7+
dependencies:
8+
- python<=3.11
9+
- pip
10+
- ipython_genutils
11+
- ipykernel
12+
- jupyterlab
13+
- numpy>=1.22
14+
- matplotlib>=3.1
15+
- pandas>=1.4
16+
- pandas-datareader
17+
- scipy
18+
- scikit-learn>=1.1
19+
- seaborn
20+
- lightgbm
21+
- pytorch
22+
- lightning
23+
- imbalanced-learn
24+
- mlflow
25+
- autogluon.common
26+
- pip:
27+
- black
28+
- 'black[jupyter]'
29+
- optuna

‎.devcontainer/noop.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file copied into the container along with environment.yml* from the parent
2+
folder. This file is included to prevents the Dockerfile COPY instruction from
3+
failing if no environment.yml is found.

‎.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# General
2+
.DS_Store
3+
.AppleDouble
4+
.LSOverride
5+
6+
# Icon must end with two \r
7+
Icon
8+
9+
# Thumbnails
10+
._*
11+
12+
# Files that might appear in the root of a volume
13+
.DocumentRevisions-V100
14+
.fseventsd
15+
.Spotlight-V100
16+
.TemporaryItems
17+
.Trashes
18+
.VolumeIcon.icns
19+
.com.apple.timemachine.donotpresent
20+
21+
# Directories potentially created on remote AFP share
22+
.AppleDB
23+
.AppleDesktop
24+
Network Trash Folder
25+
Temporary Items
26+
.apdisk

‎.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"ms-vscode-remote.remote-containers"
4+
]
5+
}

‎.vscode/launch.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "0.1.0",
3+
"configurations": [
4+
{
5+
"name": "Python: Current File",
6+
"type": "python",
7+
"request": "launch",
8+
"program": "${file}",
9+
"console": "integratedTerminal",
10+
"justMyCode": true,
11+
"cwd":"${fileDirname}"
12+
}
13+
]
14+
}

‎LICENSE

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Creative Commons Legal Code
2+
3+
CC0 1.0 Universal
4+
5+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12+
HEREUNDER.
13+
14+
Statement of Purpose
15+
16+
The laws of most jurisdictions throughout the world automatically confer
17+
exclusive Copyright and Related Rights (defined below) upon the creator
18+
and subsequent owner(s) (each and all, an "owner") of an original work of
19+
authorship and/or a database (each, a "Work").
20+
21+
Certain owners wish to permanently relinquish those rights to a Work for
22+
the purpose of contributing to a commons of creative, cultural and
23+
scientific works ("Commons") that the public can reliably and without fear
24+
of later claims of infringement build upon, modify, incorporate in other
25+
works, reuse and redistribute as freely as possible in any form whatsoever
26+
and for any purposes, including without limitation commercial purposes.
27+
These owners may contribute to the Commons to promote the ideal of a free
28+
culture and the further production of creative, cultural and scientific
29+
works, or to gain reputation or greater distribution for their Work in
30+
part through the use and efforts of others.
31+
32+
For these and/or other purposes and motivations, and without any
33+
expectation of additional consideration or compensation, the person
34+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35+
is an owner of Copyright and Related Rights in the Work, voluntarily
36+
elects to apply CC0 to the Work and publicly distribute the Work under its
37+
terms, with knowledge of his or her Copyright and Related Rights in the
38+
Work and the meaning and intended legal effect of CC0 on those rights.
39+
40+
1. Copyright and Related Rights. A Work made available under CC0 may be
41+
protected by copyright and related or neighboring rights ("Copyright and
42+
Related Rights"). Copyright and Related Rights include, but are not
43+
limited to, the following:
44+
45+
i. the right to reproduce, adapt, distribute, perform, display,
46+
communicate, and translate a Work;
47+
ii. moral rights retained by the original author(s) and/or performer(s);
48+
iii. publicity and privacy rights pertaining to a person's image or
49+
likeness depicted in a Work;
50+
iv. rights protecting against unfair competition in regards to a Work,
51+
subject to the limitations in paragraph 4(a), below;
52+
v. rights protecting the extraction, dissemination, use and reuse of data
53+
in a Work;
54+
vi. database rights (such as those arising under Directive 96/9/EC of the
55+
European Parliament and of the Council of 11 March 1996 on the legal
56+
protection of databases, and under any national implementation
57+
thereof, including any amended or successor version of such
58+
directive); and
59+
vii. other similar, equivalent or corresponding rights throughout the
60+
world based on applicable law or treaty, and any national
61+
implementations thereof.
62+
63+
2. Waiver. To the greatest extent permitted by, but not in contravention
64+
of, applicable law, Affirmer hereby overtly, fully, permanently,
65+
irrevocably and unconditionally waives, abandons, and surrenders all of
66+
Affirmer's Copyright and Related Rights and associated claims and causes
67+
of action, whether now known or unknown (including existing as well as
68+
future claims and causes of action), in the Work (i) in all territories
69+
worldwide, (ii) for the maximum duration provided by applicable law or
70+
treaty (including future time extensions), (iii) in any current or future
71+
medium and for any number of copies, and (iv) for any purpose whatsoever,
72+
including without limitation commercial, advertising or promotional
73+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74+
member of the public at large and to the detriment of Affirmer's heirs and
75+
successors, fully intending that such Waiver shall not be subject to
76+
revocation, rescission, cancellation, termination, or any other legal or
77+
equitable action to disrupt the quiet enjoyment of the Work by the public
78+
as contemplated by Affirmer's express Statement of Purpose.
79+
80+
3. Public License Fallback. Should any part of the Waiver for any reason
81+
be judged legally invalid or ineffective under applicable law, then the
82+
Waiver shall be preserved to the maximum extent permitted taking into
83+
account Affirmer's express Statement of Purpose. In addition, to the
84+
extent the Waiver is so judged Affirmer hereby grants to each affected
85+
person a royalty-free, non transferable, non sublicensable, non exclusive,
86+
irrevocable and unconditional license to exercise Affirmer's Copyright and
87+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
88+
maximum duration provided by applicable law or treaty (including future
89+
time extensions), (iii) in any current or future medium and for any number
90+
of copies, and (iv) for any purpose whatsoever, including without
91+
limitation commercial, advertising or promotional purposes (the
92+
"License"). The License shall be deemed effective as of the date CC0 was
93+
applied by Affirmer to the Work. Should any part of the License for any
94+
reason be judged legally invalid or ineffective under applicable law, such
95+
partial invalidity or ineffectiveness shall not invalidate the remainder
96+
of the License, and in such case Affirmer hereby affirms that he or she
97+
will not (i) exercise any of his or her remaining Copyright and Related
98+
Rights in the Work or (ii) assert any associated claims and causes of
99+
action with respect to the Work, in either case contrary to Affirmer's
100+
express Statement of Purpose.
101+
102+
4. Limitations and Disclaimers.
103+
104+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
105+
surrendered, licensed or otherwise affected by this document.
106+
b. Affirmer offers the Work as-is and makes no representations or
107+
warranties of any kind concerning the Work, express, implied,
108+
statutory or otherwise, including without limitation warranties of
109+
title, merchantability, fitness for a particular purpose, non
110+
infringement, or the absence of latent or other defects, accuracy, or
111+
the present or absence of errors, whether or not discoverable, all to
112+
the greatest extent permissible under applicable law.
113+
c. Affirmer disclaims responsibility for clearing rights of other persons
114+
that may apply to the Work or any use thereof, including without
115+
limitation any person's Copyright and Related Rights in the Work.
116+
Further, Affirmer disclaims responsibility for obtaining any necessary
117+
consents, permissions or other rights required for any use of the
118+
Work.
119+
d. Affirmer understands and acknowledges that Creative Commons is not a
120+
party to this document and has no duty or obligation with respect to
121+
this CC0 or use of the Work.

‎README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# VSCode dev-container (Docker) setup with Miniconda and Jupyter Notebooks
2+
3+
This is a [**containerized dev setup**](https://code.visualstudio.com/docs/devcontainers/containers) respectively related for using [**remote containers**](https://code.visualstudio.com/docs/remote/containers) to work on data science / machine learning problems using **Anaconda with VSCode**.
4+
5+
It installs [`conda/miniconda3:latest`](https://hub.docker.com/r/conda/miniconda3/) as a base image and installs ipykernel,
6+
so it supports Jupyter notebooks (installed as a VSCode extension), as well as debugging *.py files directly.
7+
8+
A conda environment is created within the dev container and can easily be configured with the desired dependencies/packages.
9+
Various VSCode extensions are installed automatically in the container as well.
10+
11+
Mac OS Install Instructions:
12+
13+
- Install Docker Desktop `brew install --cask docker`
14+
- Install VSCode `brew install --cask visual-studio-code`
15+
- Open VSCode
16+
- Install VSCode remote container extension: [ms-vscode-remote.remote-containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
17+
- Start dev container: F1 + "Open folder in container ..."
18+
- Open demo.ipynb or demo.py to try the setup
19+
20+
21+
Optional Steps:
22+
23+
- Add/remove VSCode extensions in .devcontainer/devcontainer.json
24+
- Change Anaconda environment in .devcontainer/environment.yml
25+
- Update gitignore to match your setup

‎demo.ipynb

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"ename": "",
10+
"evalue": "",
11+
"output_type": "error",
12+
"traceback": [
13+
"\u001b[1;31mJupyter cannot be started. Error attempting to locate Jupyter: Select an Interpreter to start Jupyter\n",
14+
"\u001b[1;31mRun the following command to install 'jupyter and notebook' into the Python environment. \n",
15+
"\u001b[1;31mCommand: 'python -m pip install jupyter notebook -U\n",
16+
"\u001b[1;31mor\n",
17+
"\u001b[1;31mconda install jupyter notebook -U'\n",
18+
"\u001b[1;31mClick <a href='https://aka.ms/installJupyterForVSCode'>here</a> for more info."
19+
]
20+
}
21+
],
22+
"source": [
23+
"from autogluon.tabular import TabularDataset, TabularPredictor"
24+
]
25+
},
26+
{
27+
"cell_type": "code",
28+
"execution_count": null,
29+
"metadata": {},
30+
"outputs": [],
31+
"source": [
32+
"data_root = 'https://autogluon.s3.amazonaws.com/datasets/Inc/'\n",
33+
"train_data = TabularDataset(data_root + 'train.csv')\n",
34+
"test_data = TabularDataset(data_root + 'test.csv')\n",
35+
"\n",
36+
"predictor = TabularPredictor(label='class').fit(train_data=train_data)\n",
37+
"predictions = predictor.predict(test_data)"
38+
]
39+
}
40+
],
41+
"metadata": {
42+
"interpreter": {
43+
"hash": "a7109dcfa2d8cdf324fb89d9244b4f54d7419cdde71f559ec698c0c5cbbd65ee"
44+
},
45+
"kernelspec": {
46+
"display_name": "Python 3.7.13 ('env1')",
47+
"language": "python",
48+
"name": "python3"
49+
},
50+
"language_info": {
51+
"codemirror_mode": {
52+
"name": "ipython",
53+
"version": 3
54+
},
55+
"file_extension": ".py",
56+
"mimetype": "text/x-python",
57+
"name": "python",
58+
"nbconvert_exporter": "python",
59+
"pygments_lexer": "ipython3",
60+
"version": "3.11.0"
61+
},
62+
"orig_nbformat": 4
63+
},
64+
"nbformat": 4,
65+
"nbformat_minor": 2
66+
}

‎demo.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def main():
2+
print("Hello World!")
3+
4+
if __name__ == "__main__":
5+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.