Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled workflow.include should carry print_compilation keyword #2469

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions snakemake/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, token):
class TokenAutomaton:
subautomata: Dict[str, Any] = {}
deprecated: Dict[str, str] = {}
print_compilation = False

def __init__(self, snakefile: "Snakefile", base_indent=0, dedent=0, root=True):
self.root = root
Expand Down Expand Up @@ -239,7 +240,11 @@ def keyword(self):


class Include(GlobalKeywordState):
pass
def block_content(self, token):
if self.print_compilation:
yield f"{token.string}, print_compilation=True", token
else:
yield token.string, token


class Workdir(GlobalKeywordState):
Expand Down Expand Up @@ -1202,8 +1207,9 @@ def format_tokens(tokens) -> Generator[str, None, None]:
t_ = t


def parse(path, workflow, overwrite_shellcmd=None, rulecount=0):
def parse(path, workflow, overwrite_shellcmd=None, rulecount=0, print_compilation=False):
Shell.overwrite_cmd = overwrite_shellcmd
TokenAutomaton.print_compilation = print_compilation
with Snakefile(path, workflow, rulecount=rulecount) as snakefile:
automaton = Python(snakefile)
linemap = dict()
Expand Down
1 change: 1 addition & 0 deletions snakemake/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ def include(
snakefile,
self,
rulecount=self._rulecount,
print_compilation=print_compilation,
)
self._rulecount = rulecount

Expand Down
Loading