Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dl_on_supercomputers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HPC4NS
dl_on_supercomputers
Commits
6864128b
Commit
6864128b
authored
5 years ago
by
Fahad Khalid
Browse files
Options
Downloads
Patches
Plain Diff
A bit of cleanup, and also, removed assert statements; exceptions are raised instead.
parent
713cda03
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/data_utils.py
+16
-8
16 additions, 8 deletions
utils/data_utils.py
with
16 additions
and
8 deletions
utils/data_utils.py
+
16
−
8
View file @
6864128b
...
...
@@ -9,6 +9,10 @@
import
os
class
DatasetNotFoundError
(
Exception
):
"""
Raised when the requested dataset cannot be located.
"""
class
DataValidator
:
"""
This class provides functions for validation of input data.
...
...
@@ -16,7 +20,7 @@ class DataValidator:
"""
def
__init__
(
self
):
pass
"""
No-op constructor.
"""
@staticmethod
def
validated_data_dir
(
filename
):
...
...
@@ -52,12 +56,16 @@ class DataValidator:
print
(
'
Using {} as the data directory.
'
.
format
(
data_dir
))
# Check if the directory exists
assert
os
.
path
.
exists
(
data_dir
),
\
data_dir
+
'
refers to a non-existing directory.
'
\
'
Please either correctly set the DL_TEST_DATA_HOME environment variable,
'
\
'
or make sure the datasets are available in the project root.
'
assert
os
.
path
.
exists
(
os
.
path
.
join
(
data_dir
,
filename
)),
\
'
Unable to locate
'
+
filename
+
'
in
'
+
data_dir
if
not
os
.
path
.
exists
(
data_dir
):
raise
DatasetNotFoundError
(
'
{} refers to a non-existing directory. Please either correctly set
'
'
the DL_TEST_DATA_HOME environment variable, or make sure the datasets are
'
'
available in the project root.
'
.
format
(
data_dir
)
)
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
data_dir
,
filename
)):
raise
DatasetNotFoundError
(
'
Unable to locate {} in {}
'
.
format
(
filename
,
data_dir
)
)
return
data_dir
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment