[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Apr 14 08:00:50 PDT 2017
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/fdfdab35e014/
Changeset: fdfdab35e014
Branch: yt
User: brittonsmith
Date: 2017-03-30 22:29:26+00:00
Summary: Add a safety check to ensure_dir to avoid possible collisions from multiple processes trying to make dir at once.
Affected #: 1 file
diff -r 3fee41c2ea35fbe17c97ba1dc286d6e71f088716 -r fdfdab35e014c2d4527358453a896c180faea1a0 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -804,8 +804,16 @@
def ensure_dir(path):
r"""Parallel safe directory maker."""
- if not os.path.exists(path):
+ if os.path.exists(path):
+ return path
+
+ try:
only_on_root(os.makedirs, path)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ pass
+ else:
+ raise
return path
def validate_width_tuple(width):
https://bitbucket.org/yt_analysis/yt/commits/361df61d249f/
Changeset: 361df61d249f
Branch: yt
User: brittonsmith
Date: 2017-03-30 22:34:44+00:00
Summary: Using ensure_dir in place of all mkdir calls.
Affected #: 5 files
diff -r fdfdab35e014c2d4527358453a896c180faea1a0 -r 361df61d249f71184243e9ea366aafe1f33259cd yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
@@ -20,6 +20,7 @@
from yt.config import \
ytcfg
from yt.funcs import \
+ ensure_dir, \
mylog, \
only_on_root
from yt.analysis_modules.cosmological_observation.cosmology_splice import \
@@ -112,8 +113,7 @@
self.output_prefix = output_prefix
# Create output directory.
- if not os.path.exists(self.output_dir):
- only_on_root(os.mkdir, self.output_dir)
+ ensure_dir(self.output_dir)
# Calculate light cone solution.
CosmologySplice.__init__(self, parameter_filename, simulation_type,
diff -r fdfdab35e014c2d4527358453a896c180faea1a0 -r 361df61d249f71184243e9ea366aafe1f33259cd yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -781,13 +781,7 @@
name = keyword
name = os.path.expanduser(name)
if name[-1] == os.sep and not os.path.isdir(name):
- try:
- os.mkdir(name)
- except OSError as e:
- if e.errno == errno.EEXIST:
- pass
- else:
- raise
+ ensure_dir(name)
if os.path.isdir(name):
name = os.path.join(name, keyword)
if not name.endswith(suffix):
diff -r fdfdab35e014c2d4527358453a896c180faea1a0 -r 361df61d249f71184243e9ea366aafe1f33259cd yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -31,6 +31,7 @@
ytcfg["yt","__command_line"] = "True"
from yt.startup_tasks import parser, subparsers
from yt.funcs import \
+ ensure_dir, \
ensure_list, \
get_hg_version, \
get_yt_version, \
@@ -1358,7 +1359,7 @@
data_dir = args.location
if not os.path.exists(data_dir):
print("The directory '%s' does not exist. Creating..." % data_dir)
- os.mkdir(data_dir)
+ ensure_dir(data_dir)
data_file = os.path.join(data_dir, args.filename)
if os.path.exists(data_file) and not args.overwrite:
raise IOError("File '%s' exists and overwrite=False!" % data_file)
diff -r fdfdab35e014c2d4527358453a896c180faea1a0 -r 361df61d249f71184243e9ea366aafe1f33259cd yt/utilities/parameter_file_storage.py
--- a/yt/utilities/parameter_file_storage.py
+++ b/yt/utilities/parameter_file_storage.py
@@ -18,7 +18,9 @@
from itertools import islice
from yt.config import ytcfg
-from yt.funcs import mylog
+from yt.funcs import \
+ ensure_dir, \
+ mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_simple_proxy
@@ -84,7 +86,7 @@
dbn = self._get_db_name()
dbdir = os.path.dirname(dbn)
try:
- if not os.path.isdir(dbdir): os.mkdir(dbdir)
+ if not os.path.isdir(dbdir): ensure_dir(dbdir)
except OSError:
raise NoParameterShelf()
open(dbn, 'ab') # make sure it exists, allow to close
diff -r fdfdab35e014c2d4527358453a896c180faea1a0 -r 361df61d249f71184243e9ea366aafe1f33259cd yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -34,6 +34,7 @@
from yt.funcs import \
get_image_suffix, \
get_ipython_api_version, iterable, \
+ ensure_dir, \
ensure_list
from yt.utilities.exceptions import \
YTNotInsideNotebook
@@ -576,13 +577,7 @@
name = str(self.ds)
name = os.path.expanduser(name)
if name[-1] == os.sep and not os.path.isdir(name):
- try:
- os.mkdir(name)
- except OSError as e:
- if e.errno == errno.EEXIST:
- pass
- else:
- raise
+ ensure_dir(name)
if os.path.isdir(name) and name != str(self.ds):
name = name + (os.sep if name[-1] != os.sep else '') + str(self.ds)
if suffix is None:
https://bitbucket.org/yt_analysis/yt/commits/b6b6275758d2/
Changeset: b6b6275758d2
Branch: yt
User: brittonsmith
Date: 2017-04-03 20:56:35+00:00
Summary: Removing import and only_on_root in ensure_dir. Also, make ensure_dir_exists just call ensure_dir.
Affected #: 2 files
diff -r 361df61d249f71184243e9ea366aafe1f33259cd -r b6b6275758d2d8a222c86cef234851ae2f4e7700 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -791,10 +791,7 @@
def ensure_dir_exists(path):
r"""Create all directories in path recursively in a parallel safe manner"""
my_dir = os.path.dirname(path)
- if not my_dir:
- return
- if not os.path.exists(my_dir):
- only_on_root(os.makedirs, my_dir)
+ ensure_dir(my_dir)
def ensure_dir(path):
r"""Parallel safe directory maker."""
@@ -802,7 +799,7 @@
return path
try:
- only_on_root(os.makedirs, path)
+ os.makedirs(path)
except OSError as e:
if e.errno == errno.EEXIST:
pass
diff -r 361df61d249f71184243e9ea366aafe1f33259cd -r b6b6275758d2d8a222c86cef234851ae2f4e7700 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -18,7 +18,6 @@
string_types
import base64
-import errno
import numpy as np
import matplotlib
import os
https://bitbucket.org/yt_analysis/yt/commits/8944211904ec/
Changeset: 8944211904ec
Branch: yt
User: brittonsmith
Date: 2017-04-04 17:17:25+00:00
Summary: Revert one ensure_dir call.
Affected #: 1 file
diff -r b6b6275758d2d8a222c86cef234851ae2f4e7700 -r 8944211904ec5ca72508e88679c85311cc6b4360 yt/utilities/parameter_file_storage.py
--- a/yt/utilities/parameter_file_storage.py
+++ b/yt/utilities/parameter_file_storage.py
@@ -19,7 +19,6 @@
from yt.config import ytcfg
from yt.funcs import \
- ensure_dir, \
mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_simple_proxy
@@ -86,7 +85,7 @@
dbn = self._get_db_name()
dbdir = os.path.dirname(dbn)
try:
- if not os.path.isdir(dbdir): ensure_dir(dbdir)
+ if not os.path.isdir(dbdir): os.mkdir(dbdir)
except OSError:
raise NoParameterShelf()
open(dbn, 'ab') # make sure it exists, allow to close
https://bitbucket.org/yt_analysis/yt/commits/9e2878129571/
Changeset: 9e2878129571
Branch: yt
User: ngoldbaum
Date: 2017-04-14 15:00:45+00:00
Summary: Merged in brittonsmith/yt (pull request #2570)
Ensure safety in mkdir calls
Approved-by: Nathan Goldbaum <ngoldbau at illinois.edu>
Approved-by: Kacper Kowalik <xarthisius.kk at gmail.com>
Affected #: 5 files
diff -r 4d27dc97e6a5d4c84c2747b666246250bf13d51c -r 9e28781295713809bb59bbc01d5ad1b841aab675 yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
--- a/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
+++ b/yt/analysis_modules/cosmological_observation/light_cone/light_cone.py
@@ -20,6 +20,7 @@
from yt.config import \
ytcfg
from yt.funcs import \
+ ensure_dir, \
mylog, \
only_on_root
from yt.analysis_modules.cosmological_observation.cosmology_splice import \
@@ -112,8 +113,7 @@
self.output_prefix = output_prefix
# Create output directory.
- if not os.path.exists(self.output_dir):
- only_on_root(os.mkdir, self.output_dir)
+ ensure_dir(self.output_dir)
# Calculate light cone solution.
CosmologySplice.__init__(self, parameter_filename, simulation_type,
diff -r 4d27dc97e6a5d4c84c2747b666246250bf13d51c -r 9e28781295713809bb59bbc01d5ad1b841aab675 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -781,13 +781,7 @@
name = keyword
name = os.path.expanduser(name)
if name[-1] == os.sep and not os.path.isdir(name):
- try:
- os.mkdir(name)
- except OSError as e:
- if e.errno == errno.EEXIST:
- pass
- else:
- raise
+ ensure_dir(name)
if os.path.isdir(name):
name = os.path.join(name, keyword)
if not name.endswith(suffix):
@@ -797,15 +791,20 @@
def ensure_dir_exists(path):
r"""Create all directories in path recursively in a parallel safe manner"""
my_dir = os.path.dirname(path)
- if not my_dir:
- return
- if not os.path.exists(my_dir):
- only_on_root(os.makedirs, my_dir)
+ ensure_dir(my_dir)
def ensure_dir(path):
r"""Parallel safe directory maker."""
- if not os.path.exists(path):
- only_on_root(os.makedirs, path)
+ if os.path.exists(path):
+ return path
+
+ try:
+ os.makedirs(path)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ pass
+ else:
+ raise
return path
def validate_width_tuple(width):
diff -r 4d27dc97e6a5d4c84c2747b666246250bf13d51c -r 9e28781295713809bb59bbc01d5ad1b841aab675 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -31,6 +31,7 @@
ytcfg["yt","__command_line"] = "True"
from yt.startup_tasks import parser, subparsers
from yt.funcs import \
+ ensure_dir, \
ensure_list, \
get_hg_version, \
get_yt_version, \
@@ -1358,7 +1359,7 @@
data_dir = args.location
if not os.path.exists(data_dir):
print("The directory '%s' does not exist. Creating..." % data_dir)
- os.mkdir(data_dir)
+ ensure_dir(data_dir)
data_file = os.path.join(data_dir, args.filename)
if os.path.exists(data_file) and not args.overwrite:
raise IOError("File '%s' exists and overwrite=False!" % data_file)
diff -r 4d27dc97e6a5d4c84c2747b666246250bf13d51c -r 9e28781295713809bb59bbc01d5ad1b841aab675 yt/utilities/parameter_file_storage.py
--- a/yt/utilities/parameter_file_storage.py
+++ b/yt/utilities/parameter_file_storage.py
@@ -18,7 +18,8 @@
from itertools import islice
from yt.config import ytcfg
-from yt.funcs import mylog
+from yt.funcs import \
+ mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import \
parallel_simple_proxy
diff -r 4d27dc97e6a5d4c84c2747b666246250bf13d51c -r 9e28781295713809bb59bbc01d5ad1b841aab675 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -18,7 +18,6 @@
string_types
import base64
-import errno
import numpy as np
import matplotlib
import os
@@ -34,6 +33,7 @@
from yt.funcs import \
get_image_suffix, \
get_ipython_api_version, iterable, \
+ ensure_dir, \
ensure_list
from yt.utilities.exceptions import \
YTNotInsideNotebook
@@ -576,13 +576,7 @@
name = str(self.ds)
name = os.path.expanduser(name)
if name[-1] == os.sep and not os.path.isdir(name):
- try:
- os.mkdir(name)
- except OSError as e:
- if e.errno == errno.EEXIST:
- pass
- else:
- raise
+ ensure_dir(name)
if os.path.isdir(name) and name != str(self.ds):
name = name + (os.sep if name[-1] != os.sep else '') + str(self.ds)
if suffix is None:
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list