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

Commit 7254b94

Browse files
committed
Untested/dirty end of the week commit
1 parent 270f76a commit 7254b94

File tree

4 files changed

+98
-14
lines changed

4 files changed

+98
-14
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ benchmark:
77
snakemake -p --cores 1
88
dry:
99
snakemake -p --cores 1 -n -p -F
10+
clean:
11+
rm -rf ./out ./log

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Powered by Snakemake
88
- `make activate` to activate the environment with the dependencies (pipenv shell)
99
- `make benchmark` to run the benchmark (= trigger the Snakefile)
1010
- `make dry` to dry run the benchmark (= dry run the Snakefile)
11+
- `make clean` deletes the `./out` and `./log` output folders
1112

1213
# Rationale
1314

Snakefile

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ for stage in get_benchmark_stages():
3030
print(' Params:', get_module_parameters(stage, module))
3131
print('------')
3232

33+
3334
## benchmark seeding (datasets and wildcard generation) ##############################################
3435

3536
# print(list(get_stage_outputs('out').values()))
@@ -116,8 +117,70 @@ rule done:
116117
op.join('log', 'done.txt')
117118
shell:
118119
"date > {output}"
119-
120-
## sandbox
120+
121+
122+
123+
124+
125+
126+
127+
## sandbox ------------------------------------------------------------------------------
121128
## not tested yet
122129
# wildcard_constraints:
123130
# dataset='/'.join([re.escape(x) for x in get_initial_datasets()])
131+
132+
133+
silence_sandbox = True
134+
if silence_sandbox:
135+
sys.stdout = open(os.devnull, "w")
136+
sys.stderr = open(os.devnull, "w")
137+
138+
### sandbox start
139+
print('--------------------------------------------------------here')
140+
141+
# print(get_deepest_input_dirname('methods'))
142+
# print(get_deepest_input_dirname('metrics'))
143+
144+
145+
# building a lookup dict tag (format, i.e. 'counts'): deliverables (full paths)
146+
#
147+
# print(get_stage_output_dict('data'))
148+
## tp stands for template
149+
lookup = dict()
150+
for stage in get_benchmark_stages():
151+
print(stage)
152+
if is_initial(stage):
153+
o_tps = get_stage_output_dict(stage)
154+
for o_tp in o_tps:
155+
for module in get_modules_by_stage(stage):
156+
for output_key in o_tp.keys():
157+
lookup.update({output_key : o_tp[output_key].format(mod = module,
158+
stage = stage,
159+
params = 'default',
160+
id = module)})
161+
elif is_terminal(stage):
162+
## todo update
163+
pass
164+
else:
165+
## implicit means explicit - not intuitive at all
166+
i_tps = get_stage_implicit_inputs(stage)
167+
o_tps = get_stage_outputs(stage)
168+
print('inputs are', i_tps)
169+
print('outputs are', o_tps)
170+
for i_tp in i_tps:
171+
excl = get_module_excludes(stage, module)
172+
for module in list(set(modules) - set(excl)):
173+
print('here')
174+
print(lookup)
175+
176+
# else:
177+
# for module in get_modules_by_stage(stage):
178+
# ii = get_stage_implicit_inputs(stage)
179+
# print(ii.keys())
180+
# print(ii.values())
181+
182+
183+
print('--------------------------------------------------------here')
184+
185+
186+
### sandbox end

src/workflow_helpers.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@ def get_stage_implicit_inputs(stage):
5050
return(None)
5151
return(config['stages'][stage]['inputs'])
5252

53-
def get_stage_outputs(stage):
53+
def get_stage_output_dict(stage):
5454
if 'terminal' in config['stages'][stage].keys() and config['stages'][stage]['terminal']:
5555
return(None)
5656
L = config['stages'][stage]['outputs']
57-
return(dict(pair for d in L for pair in d.items()))
57+
return(L)
5858

59+
def get_stage_outputs(stage):
60+
if 'terminal' in config['stages'][stage].keys() and config['stages'][stage]['terminal']:
61+
return(None)
62+
L = config['stages'][stage]['outputs']
63+
return(dict(pair for d in L for pair in d.items()))
5964

65+
6066
def get_stage_explicit_inputs(stage):
6167
implicit = get_stage_implicit_inputs(stage)
6268
explicit = implicit
@@ -128,17 +134,20 @@ def count_path_depth(path):
128134
## and 'meta' from raw, then we have to nest outputs after the longest (deepest) folder -
129135
## that is, raw/processed/here, and not to raw/here
130136
def get_deepest_input_dirname(stage):
131-
i = get_stage_explicit_inputs(stage)
132-
deepest_input = '.'
133-
if i is not None:
137+
ii = get_stage_implicit_inputs(stage)
138+
deepest_inputs = []
139+
if ii is not None:
140+
deepest_input = '.'
134141
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+
for input_dict in ii:
143+
for item in input_dict.keys():
144+
curr_depth = count_path_depth(input_dict[item])
145+
if curr_depth > deepest_input_depth:
146+
deepest_input_depth = curr_depth
147+
deepest_input = op.dirname(input_dict[item])
148+
deepest_inputs.append(deepest_input)
149+
150+
return(deepest_inputs)
142151

143152
## with substituted module/stage/ids
144153
def fill_explicit_outputs(stage, module):
@@ -151,3 +160,12 @@ def fill_explicit_outputs(stage, module):
151160

152161
def nest_deliverable_path(parent, path):
153162
return(op.join(parent, path))
163+
164+
## using the input identifiers, excludes and parameters and not 'after' clauses
165+
def traverse_yaml():
166+
lookup = ''
167+
for stage in get_benchmark_stages():
168+
for module in get_modules_by_stage(stage):
169+
ii = get_stage_implicit_inputs(stage)
170+
return(todo)
171+

0 commit comments

Comments
 (0)