Skip to content

SkyTruth/mtm

Repository files navigation

Moutaintop Removal Mining

This repository contains code, data, and documentation for SkyTruth's Mountaintop Removal Mining (MTM) related work.

Repository Directories

Working in this repo:

  • This repo is primarily Python-based, so ensure you have python set up. if not, follow the Python setup instructions.
  • This repo is set up with Poetry. Learn how to set up and use Poetry in this section, which mainly re-format data.
  • We use Google Cloud Platform resources (Google Cloud Storage) in this repo. Instructions on getting set up are here
  • In this repo we use pre-commit-hooks
  • Git/GitHub instructions are found in this repo
  • In this repo, each MTM related project has a separate directory which contains documentation about the project. Projects are outlined broadly in Repository Layout, please see specific ReadMe files in each directory for additional information

Python Setup

  • Python should come built in on Mac, but you can also get it from the Python downloads page. These instructions are only for Windows though.
  • Install the latest stable Python version (if you do not already have it)
    • Download and install from Python
  • Add the Python path to your environment variables (be sure to update YourUsername and the correct python version [in this example, the version is Python3.9]) by running the following in Powershell:
$env:Path += ";C:\Users\<YourUsername>\AppData\Local\Programs\Python\Python39\"
  • Test that python is set up correctly. First restart your Powershell and then run:
py --version

Poetry Installation and Set-up

Note: Python needs to be installed before poetry

Mac / Linux

  1. Install Poetry
  2. After installing poetry, add the Poetry bin to PATH by adding the following line to .zshrc:
export PATH="$HOME/.local/bin:$PATH"

Windows

  1. Open PowerShell in Administrator mode (windows menu > Powershell > right click > Administrator)
  2. Install Poetry:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
  • It is probably possible (and better) to add the PATH to the Poetry app to your environment somehow, but we could not figure out how to make that work so instead we set up an Alias so that we could run poetry commands
  1. Set execution policy (this makes your computer slightly less secure, but if you aren't downloading potential malware via Powershell, you're alright)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
  1. create user profile: open $PROFILE in notepad:
notepad $PROFILE
  1. Add the following to that file (replace YourUsername with the correct identifier):
Set-Alias poetry "C:\Users\<YourUsername>\AppData\Roaming\Python\Scripts\poetry.exe"

Using Poetry

Working in the poetry environment

This repo already has a pyproject.toml and a poetry.lock file. These define the virtual environment (sort of like how requirements.txt defines a pip environment, but these files resolve dependencies and ensure everyone has the same dependencies, since those are defined in the lockfile)

To work in the poetry virtual environment, you just need to prepend all command line statements with poetry run (i.e. instead of python hello_world.py you would simply run poetry run python hello_world.py)

Alternatively, you can work work entirely in the environment (similar to conda activate) with the command poetry shell, and then you can just run python hello_world.py

Build lockfile and install environment

Do this each time you pull the repo in case there have been changes to the lockfiles:

poetry lock
poetry install
  • poetry lock builds the lockfile, which is the list of dependencies based on pyproject.toml (core dependencies)
  • poetry install installs those dependencies

Updating the environment

Adding a new library:

poetry add <new-package>

Deleting a library

poetry remove <old-package>

License

This work is licensed under the Apache License, Version 2.0. See LICENSE.txt

About

Mountaintop Mining

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8