Skip to content

Commit

Permalink
Merge pull request #50 from IceCubeOpenSource/robust-paths
Browse files Browse the repository at this point in the history
Robust paths
  • Loading branch information
sgriswol authored Jul 1, 2020
2 parents 906b0d0 + f0da726 commit 21e2f9c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
test-results.xml

# ASTERIA User areas
# ASTERIA User areas, ignore all files in these directories other than the gitignores
scratch/*
!scratch/.gitignore
data/processed/*
!data/processed/.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
5 changes: 5 additions & 0 deletions data/processed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore all files in this directory
*

# Do not ignore this .gitignore
!.gitignore
7 changes: 5 additions & 2 deletions python/asteria/IO.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os.path import isfile
from os.path import isfile, isdir, dirname
from .neutrino import Flavor

import numpy as np
Expand Down Expand Up @@ -197,7 +197,10 @@ def find(group, Interactions, Hierarchy, Flavors, Enu, time):

def save(config, Interactions, Hierarchy, Flavors, Enu, time, result, force=False):
h5path = '/'.join([config.abs_base_path, config.IO.table.path])


if not isdir(dirname(h5path)):
raise NotADirectoryError('Directory {0} not found, aborting.'.format(dirname(h5path)))

# Test file existence
if not isfile(h5path):
print('Creating file: {}'.format(h5path))
Expand Down
15 changes: 0 additions & 15 deletions python/asteria/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,3 @@
"""
from __future__ import absolute_import
from ._version import __version__
import os


src_path = os.path.realpath(__path__[0])
base_path = os.sep.join(src_path.split(os.sep)[:-2])

# Test for existence of scratch directory
scratch_path = os.path.join(base_path, 'scratch')
if not os.path.isdir(scratch_path):
os.mkdir(scratch_path)

# Test for existence of processed directory
processed_path = os.path.join(base_path, 'data', 'processed')
if not os.path.isdir(processed_path):
os.mkdir(processed_path)
5 changes: 5 additions & 0 deletions scratch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore all files in this directory
*

# Do not ignore this .gitignore
!.gitignore

0 comments on commit 21e2f9c

Please sign in to comment.