Skip to content
This repository was archived by the owner on Aug 27, 2024. It is now read-only.

Commit 270f76a

Browse files
committed
Start sketching the adaptative file path system
1 parent 00f11b3 commit 270f76a

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

Snakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ for stage in get_benchmark_stages():
9898
rule:
9999
name: 'flat_module_maker' # not hierarchical/nested yet
100100
input:
101-
op.join('out', "{module}.flag")
101+
flag = op.join('out', "{module}.flag")
102102
output:
103103
op.join('out', "{stage}", "{module}", "{params}",
104104
"{stage}_{module}_{params}_{id}_another.txt")

src/workflow_helpers.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# import dag
1010
import os.path as op
11+
import os
1112
import sys
1213

1314
def clone_repo(module_name):
@@ -108,6 +109,9 @@ def get_initial_dataset_paths(dataset):
108109

109110
return(sum(filled, []))
110111

112+
113+
## playground -------------
114+
111115
# dirty, fix
112116
def write_module_flag_for_dirty_module_wildcards(module):
113117
## creates an empty file
@@ -117,8 +121,33 @@ def write_module_flag_for_dirty_module_wildcards(module):
117121
def tokenize_parameters():
118122
print('todo')
119123

120-
def exclude_items_from_explicit_outputs():
121-
print('todo')
124+
def count_path_depth(path):
125+
return(path.count(os.sep))
126+
127+
## if a module (stage) gets inputs from different modules, i.e. counts from 'processed' after 'raw'
128+
## and 'meta' from raw, then we have to nest outputs after the longest (deepest) folder -
129+
## that is, raw/processed/here, and not to raw/here
130+
def get_deepest_input_dirname(stage):
131+
i = get_stage_explicit_inputs(stage)
132+
deepest_input = '.'
133+
if i is not None:
134+
deepest_input_depth = 0
135+
for item in i.keys():
136+
curr_depth = count_path_depth(i[item])
137+
if curr_depth > deepest_input_depth:
138+
deepest_input_depth = curr_depth
139+
deepest_input = op.dirname(i[item])
140+
return('this breaks because explicit inputs are lists - raw vs processed; iterate instead')
141+
142+
143+
## with substituted module/stage/ids
144+
def fill_explicit_outputs(stage, module):
145+
i = get_stage_explicit_outputs(stage)
146+
idir = get_deepest_input_dirname(stage)
122147

123-
def nest_deliverable_paths():
124-
print('todo')
148+
oe = get_stage_outputs(stage)
149+
excludes = get_module_excludes(stage = stage, module = module)
150+
return('todo')
151+
152+
def nest_deliverable_path(parent, path):
153+
return(op.join(parent, path))

0 commit comments

Comments
 (0)