Skip to content

Commit

Permalink
adjusted test graphs to filepath treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
awicenec committed Mar 2, 2023
1 parent 5226c38 commit 3fc31d4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 26 deletions.
33 changes: 21 additions & 12 deletions daliuge-engine/dlg/data/drops/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,26 @@ def initialize(self, **kwargs):
"""
FileDROP-specific initialization.
"""
self.filepath = self.parameters.get("filepath", None)

filepath = self.sanitize_paths(self.filepath)
if filepath and filepath[-1] == "/":
self.is_dir = True
if filepath and os.path.isdir(filepath):
filename = None
dirname = filepath
else:
filename = os.path.basename(filepath) if filepath else None
dirname = os.path.dirname(filepath) if filepath else None
filepath = self.parameters.get("filepath", None)
dirname = None
filename = None

if filepath: # if there is anything provided
if filepath.count("/") == 0: # just a name
filename = filepath
dirname = self.get_dir(".")
# filepath = self.sanitize_paths(self.filepath)
elif filepath[-1] == "/": # just a directory name
self.is_dir = True
filename = None
dirname = filepath
else:
filename = os.path.basename(filepath)
dirname = os.path.dirname(filepath)
if dirname is None:
dirname = "."
filename = os.path.expandvars(filename) if filename else None
dirname = self.sanitize_paths(dirname) if dirname else None
# We later check if the file exists, but only if the user has specified
# an absolute dirname/filepath (otherwise it doesn't make sense, since
# we create our own filenames/dirnames dynamically as necessary
Expand All @@ -128,7 +137,7 @@ def initialize(self, **kwargs):
check = self.check_filepath_exists

# Default filename to drop UID
if not filename and not self.is_dir:
if filename is None:
filename = self.non_fname_chars.sub("_", self.uid)
self.filename = filename
self.dirname = self.get_dir(dirname)
Expand Down
8 changes: 4 additions & 4 deletions daliuge-engine/test/graphs/ArrayLoopPG.graph
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
],
"loop_cxt": "0",
"dw": 5,
"check_filepath_exists": true,
"check_filepath_exists": false,
"data_volume": 5,
"group_end": false,
"filepath": "",
Expand Down Expand Up @@ -248,7 +248,7 @@
],
"loop_cxt": "1",
"dw": 5,
"check_filepath_exists": true,
"check_filepath_exists": false,
"data_volume": 5,
"group_end": false,
"filepath": "",
Expand Down Expand Up @@ -277,7 +277,7 @@
],
"loop_cxt": "0",
"dw": 5,
"check_filepath_exists": true,
"check_filepath_exists": false,
"data_volume": 5,
"group_end": false,
"filepath": "",
Expand Down Expand Up @@ -306,7 +306,7 @@
],
"loop_cxt": "1",
"dw": 5,
"check_filepath_exists": true,
"check_filepath_exists": false,
"data_volume": 5,
"group_end": false,
"filepath": "",
Expand Down
4 changes: 2 additions & 2 deletions daliuge-engine/test/graphs/ddTest.graph
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
],
"loop_cxt": null,
"dw": 5,
"check_filepath_exists": true,
"check_filepath_exists": false,
"data_volume": 5,
"group_end": false,
"filepath": "",
Expand Down Expand Up @@ -116,7 +116,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "True",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down
4 changes: 2 additions & 2 deletions daliuge-engine/test/graphs/funcTestPG.graph
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down Expand Up @@ -221,7 +221,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down
4 changes: 2 additions & 2 deletions daliuge-engine/test/graphs/funcTestPG_namedPorts.graph
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down Expand Up @@ -256,7 +256,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down
6 changes: 3 additions & 3 deletions daliuge-engine/test/graphs/pyfunc_glob_testPG.graph
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down Expand Up @@ -259,7 +259,7 @@
"applicationArgs": {
"check_filepath_exists": {
"text": "Check file path exists",
"value": true,
"value": false,
"defaultValue": "",
"description": "Perform a check to make sure the file path exists before proceeding with the application",
"readonly": false,
Expand Down Expand Up @@ -350,7 +350,7 @@
],
"loop_cxt": null,
"dw": 5,
"check_filepath_exists": true,
"check_filepath_exists": false,
"data_volume": 5,
"group_end": false,
"filepath": "",
Expand Down
2 changes: 1 addition & 1 deletion daliuge-engine/test/test_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def assertFiles(
a = FileDROP(
"a",
"a",
filepath=tempDir,
filepath=tempDir + "/",
delete_parent_directory=delete_parent_directory,
)
a.write(b" ")
Expand Down

0 comments on commit 3fc31d4

Please sign in to comment.