Open moritzschaefer opened 8 months ago
Hi,
I would also be interested in this feature and took some time to look into it.
As a temporary workaround, I saw that there is a mock_snakemake()
function in the PyPSA/pypsa-eur repository that does something along those line (link to original PR. I'm attaching below a simplified version of their helpers.py
file with only that function and a small wrapper I created to do a try/except so that scripts would work both with snakemake
and with a regular IPython or Python session.
@johanneskoester would there be interest for a feature like this? If so I would be happy to try to contribute. I guess that within Snakemake the mock_snakemake()
would not be an optimal implementation? I can see at least two paths to achieve this:
PythonScript
, but instead of execute_script()
after write_script()
, snakemake could:
mock_snakemake
(or my slightly modified mockwrap()
below) so that users who want to leverage this feature have to explicitly indicate it. The advantage of this would be that the preamble is dynamically re-generated every time the script is run.Let me know if I should explore one of the following options. I'm new to Snakemake so there might very well be something I overlooked that makes this impossible or more complicated than I thought.
Thank you!
(Fixing this might also help with #247 and #2932 re debugging snakemake script with any editor's debugger)
Is your feature request related to a problem? Please describe. I like to write scripts interactively (as is nicely supported via
--edit-notebook
), but I dislike the jupyter notebook ecosystem.Describe the solution you'd like It would be great to have an option
--draft-script
or--print-snakemake-object-python
that prints the python code to populate thesnakemake
object, as in the first cell of the notebook launched by--edit-notebook
.Describe alternatives you've considered
Additional context
--draft-org
of--draft-notebook
would be exactly what I need. But understand that it's probably too niche to support it. The proposed feature above would serve sufficiently though.