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

fix: Issue #1253 (problems editing Jupyter Notebooks) #1255

Merged
merged 2 commits into from Nov 23, 2021

Conversation

bhjolly
Copy link
Contributor

@bhjolly bhjolly commented Nov 10, 2021

Description

Snakemake 6.10 was unable to open Jupyter Notebooks for editing as the use of LocalSourceFile objects for file paths was not supported in notebook.py or script.py (affecting Notebooks). This PR addresses that issue (logged as GH Issue #1253 )

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

@bhjolly bhjolly requested a review from johanneskoester as a code owner Nov 10, 2021
@bhjolly bhjolly changed the title Fix Issue #1253 fix: Issue #1253 (problems editing Jupyter Notebooks) Nov 10, 2021
@@ -42,12 +42,12 @@ def draft(self, listen):

nb["cells"].append(nbformat.v4.new_code_cell("# start coding here"))

os.makedirs(os.path.dirname(self.local_path), exist_ok=True)
os.makedirs(os.path.dirname(str(self.local_path)), exist_ok=True)
Copy link
Contributor

@johanneskoester johanneskoester Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use self.local_path.get_path_or_uri() here? That is more idiomatic with the new API.

Copy link
Contributor

@johanneskoester johanneskoester Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And in all str() occurrences below as well.

@@ -393,7 +393,7 @@ def evaluate(self, edit=False):

@property
def local_path(self):
path = self.path[7:]
path = str(self.path)#[7:]
Copy link
Contributor

@johanneskoester johanneskoester Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I'd rather rely on the SourceFile methods for checking whether the path is absolute or not and so on.

Copy link
Contributor

@johanneskoester johanneskoester left a comment

I've quickly made the modifications myself. THanks a lot for the initial approach, it was a very helpful pointer to the source of the problem!

@sonarcloud
Copy link

sonarcloud bot commented Nov 23, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@johanneskoester johanneskoester merged commit 3398ddf into snakemake:main Nov 23, 2021
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants