Skip to content

Commit

Permalink
Fix scripts to run w/o .pudl.yml, create user environment.yml
Browse files Browse the repository at this point in the history
Fixed try/except logic in setup module to catch FileNotFoundError
correctly, and return None for pudl_in and pudl_out if there's no
default file supplied by the user.

Closes #406

Also created a separate "user" environment.yml file that is stored in
`package_data` and deployed by the `pudl_setup` script, which installed
catalystcoop.pudl using conda... or at least, it will, when the package
is available on conda-forge.  Will still need to figure out what the
right way is to bootstrap the user into that conda environment, but
that's a documentation issue.  Will also obviously need to test the
environment.yml file deployed in a clean environment.

Progress toward #383
  • Loading branch information
zaneselvans committed Sep 11, 2019
1 parent 3dd26f3 commit 7b6d073
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: pudl
name: pudl-dev
channels:
- conda-forge
- defaults
Expand All @@ -21,7 +21,7 @@ dependencies:
- jedi # dev
- jupyter # user
- jupyterlab # user
- matplotlib # user
- matplotlib # base
- nbval # dev
- networkx>=2.2 # base We depend on features introduced in v2.2
- numpy # base
Expand Down
11 changes: 11 additions & 0 deletions src/pudl/package_data/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pudl
channels:
- conda-forge
- defaults
dependencies:
- catalystcoop.pudl
- dask
- jupyter
- jupyterlab
- pip
- python>=3.7
16 changes: 10 additions & 6 deletions src/pudl/workspace/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ def get_defaults():
"""
settings_file = pathlib.Path.home() / '.pudl.yml'

with pathlib.Path(settings_file).open() as f:
try:
try:
with pathlib.Path(settings_file).open() as f:
default_workspace = yaml.safe_load(f)
except FileNotFoundError:
logger.warning("PUDL user settings file .pudl.yml not found.")
default_workspace = {"pudl_in": None, "pudl_out": None}
return default_workspace
except FileNotFoundError:
logger.warning("PUDL user settings file .pudl.yml not found.")
default_workspace = {"pudl_in": None, "pudl_out": None}
return default_workspace

# Ensure that no matter what the user has put in this file, we get fully
# specified absolute paths out when we read it:
Expand Down Expand Up @@ -189,6 +189,10 @@ def init(pudl_in, pudl_out, clobber=False):
notebook_pkg = "pudl.package_data.notebooks"
deploy(notebook_pkg, notebook_dir, ignore_files, clobber=clobber)

# Deploy the pudl user environment file.
environment_pkg = "pudl.package_data"
deploy(environment_pkg, ps["pudl_out"], ignore_files, clobber=clobber)


def deploy(pkg_path, deploy_dir, ignore_files, clobber=False):
"""
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ commands =
{[testenv:linters]commands}
{[testenv:docs]commands}
{[testenv:etl]commands}
pudl_setup
pudl_setup --help
pudl_data --help
ferc1_to_sqlite --help
pudl_etl --help
Expand Down

0 comments on commit 7b6d073

Please sign in to comment.