Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpelchat04 committed Feb 3, 2022
2 parents 45875f5 + 2123352 commit 8396727
Show file tree
Hide file tree
Showing 94 changed files with 5,074 additions and 3,988 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/github-actions-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: GitHub Actions Demo
on: [push, pull_request]
jobs:
Github-Actions-CI:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
- run: |
echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env create --file environment.yml
- name: test GDL's 3 major modes
run: |
source /usr/share/miniconda/etc/profile.d/conda.sh
conda activate geo_deep_env
unzip ./data/massachusetts_buildings.zip -d ./data
python GDL.py mode=sampling
python GDL.py mode=train
python GDL.py mode=inference
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM continuumio/miniconda3

WORKDIR /app

# Create the environment:
COPY environment.yml .
RUN conda env create -f environment.yml

# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "geo_deep_env", "/bin/bash", "-c"]

# Make sure the environment is activated:
RUN echo "Make sure flask is installed:"
RUN python -c "import flask"

# The code to run when container is started:
#COPY run.py .
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "geo_deep_env", "python"]
80 changes: 80 additions & 0 deletions GDL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os
import time
import hydra
import logging
from omegaconf import DictConfig, OmegaConf, open_dict
from utils.utils import load_obj, print_config, get_git_hash, getpath


@hydra.main(config_path="config", config_name="gdl_config_template")
def run_gdl(cfg: DictConfig) -> None:
"""
Function general for Geo Deep-Learning using Hydra library to rules all the
parameters and functions using during the task wanted to execute.
Process
-------
1. Read and convert the `gdl_config.yaml` to a dictionary.
2. Verify if the code and other information need to be save.
3. If the debug option is activate, the entire config yaml will be printed
and save in a log. In addition of that, if the mode is `train`, a
validation run will precede the training to assure the well functioning
of the code.
4. Verify is the chosen mode is available.
5. Verify is the chosen task is available and run the code link to that
task.
-------
:param cfg: (DictConfig) Parameters and functions in the main yaml config
file.
"""
cfg = OmegaConf.create(cfg)

# debug config
if cfg.debug:
pass
# cfg.training.num_sanity_val_steps = 1 # only work with pytorch lightning
# logging.info(OmegaConf.to_yaml(cfg, resolve=True))

# check if the mode is chosen
if type(cfg.mode) is DictConfig:
msg = "You need to choose between those modes: {}"
raise logging.critical(msg.format(list(cfg.mode.keys())))

# save all overwritten parameters
logging.info('\nOverwritten parameters in the config: \n' + cfg.general.config_override_dirname)

# Start -----------------------------------
msg = "Let's start {} for {} !!!".format(cfg.mode, cfg.task.task_name)
logging.info(
"\n" + "-" * len(msg) + "\n" + msg +
"\n" + "-" * len(msg)
)
# -----------------------------------------

# Start the timer
start_time = time.time()
# Read the task and execute it
task = load_obj(cfg.task.path_task_function)
task(cfg)

# Add git hash from current commit to parameters.
with open_dict(cfg):
cfg.general.git_hash = get_git_hash()

# Pretty print config using Rich library
if cfg.get("print_config"):
print_config(cfg, resolve=True)

# End --------------------------------
msg = "End of {} !!!".format(cfg.mode)
logging.info(
"\n" + "-" * len(msg) + "\n" + msg + "\n" +
"Elapsed time: {:.2f}s".format(time.time() - start_time) +
"\n" + "-" * len(msg) + "\n"
)
# ------------------------------------


if __name__ == '__main__':
run_gdl()
Loading

0 comments on commit 8396727

Please sign in to comment.