Skip to content

Fix: Remove spurious nodes in dot files due to \n #268

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

Merged
merged 4 commits into from
Mar 13, 2024
Merged

Conversation

f-allian
Copy link
Contributor

Fixes issue #258 by:

  1. Reading in the dot file,
  2. Removing any new lines,
  3. Passing the contents back into pydot.

@f-allian f-allian added the bug Something isn't working label Mar 12, 2024
@f-allian f-allian self-assigned this Mar 12, 2024
Copy link

github-actions bot commented Mar 12, 2024

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Elapsed time
⚠️ PYTHON black 29 1 1.44s
✅ PYTHON pylint 29 0 4.25s

See detailed report in MegaLinter reports

MegaLinter is graciously provided by OX Security

Copy link

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.60%. Comparing base (b8ad419) to head (f9db25d).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #268   +/-   ##
=======================================
  Coverage   95.59%   95.60%           
=======================================
  Files          22       22           
  Lines        1567     1569    +2     
=======================================
+ Hits         1498     1500    +2     
  Misses         69       69           
Files Coverage Δ
causal_testing/specification/causal_dag.py 98.90% <100.00%> (+0.01%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d9b1d7...f9db25d. Read the comment docs.

Copy link
Contributor

@jmafoster1 jmafoster1 left a comment

Choose a reason for hiding this comment

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

This is such a simple solution! I love it! I'm seeing a couple of pylint/black issues that might need looking at before merging, although I can't see what they are so they might be errors or something...

Copy link
Contributor

@christopher-wild christopher-wild left a comment

Choose a reason for hiding this comment

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

Looks like a good solution to me

@@ -133,7 +133,9 @@ class CausalDAG(nx.DiGraph):
def __init__(self, dot_path: str = None, **attr):
super().__init__(**attr)
if dot_path:
pydot_graph = pydot.graph_from_dot_file(dot_path)
with open(dot_path, 'r', encoding='utf-8') as file:
dot_content = file.read().replace('\n', '')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it may be worth adding a comment describing this, as the problem this is solving is not obvious from the code.

@f-allian f-allian marked this pull request as ready for review March 12, 2024 11:57
@f-allian f-allian merged commit 5230bfc into main Mar 13, 2024
@f-allian f-allian deleted the f-allian-fix-nodes branch March 13, 2024 10:48
@f-allian f-allian linked an issue Apr 9, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spurious node when reading in causal DAG DOT files
3 participants