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

Update readme #506

Merged
merged 3 commits into from
Nov 20, 2024
Merged

Update readme #506

merged 3 commits into from
Nov 20, 2024

Conversation

jan-janssen
Copy link
Member

@jan-janssen jan-janssen commented Nov 20, 2024

Summary by CodeRabbit

  • Documentation
    • Enhanced navigability in the README.md with added hyperlinks to key sections.
    • Improved clarity and context in docs/installation.md with updated installation instructions and links to relevant documentation.
    • Restructured sections on caching and flux framework for better readability and accessibility.
    • Expanded guidance for installing dependencies and creating a Jupyter kernel for flux.
    • Updated Jupyter notebooks with clearer explanations, refined code examples, and added links to relevant documentation for better user experience.
    • Enhanced troubleshooting documentation with additional links and structured information on dependencies and resource management.

Copy link
Contributor

coderabbitai bot commented Nov 20, 2024

Walkthrough

The changes in this pull request focus on enhancing the documentation for the executorlib library. Key updates include the addition of hyperlinks to various sections in the README.md and docs/installation.md files, improving navigability and access to related information. The restructuring of content, particularly around installation instructions and caching, aims to clarify usage and installation processes. New entries have been added to the documentation to provide a more comprehensive outline of the library's features, without altering any exported or public entity declarations.

Changes

File Change Summary
README.md Added hyperlinks for "HPC Submission Mode," "HPC Allocation Mode," "Local Mode," "resource dictionary," and "SLURM with flux." Adjusted formatting and examples for clarity, including code snippets for the Executor class. Reorganized documentation with new entries like "Minimal," "MPI Support," and "Caching."
docs/installation.md Enhanced clarity with added hyperlinks for "Local Mode," "HPC Allocation Mode," and "HPC Submission Mode." Restructured caching section, updated installation instructions for h5py, and improved flux framework documentation. Expanded Jupyter integration instructions and updated visualization section with pygraphviz installation details.
docs/development.md Deleted file containing comprehensive documentation for executorlib, including sections on contributions, licensing, and package functionality.
docs/trouble_shooting.md Updated with links for "Message Passing Interface," "Missing Dependencies," and expanded "Resource Dictionary" section for clarity.
notebooks/*.ipynb Enhanced documentation and code examples across multiple notebooks, including clearer explanations, refined examples for Executor usage, and added links to relevant documentation sections.

Possibly related PRs

  • Add trouble shooting #404: The changes in the README.md and docs/trouble_shooting.md both focus on enhancing documentation usability, including adding hyperlinks to various sections, which aligns with the main PR's goal of improving documentation accessibility.
  • Remove h5io from dependencies #417: The removal of the h5io dependency in this PR relates to the main PR's updates in documentation regarding resource management, as both involve clarifying and refining the library's usage.
  • Delete SubprocessExecutor and ShellExecutor #440: The deletion of the SubprocessExecutor and ShellExecutor classes and the focus on the Executor class in this PR connects with the main PR's emphasis on improving documentation for the Executor class.
  • Cache: Use explicit arguments for serialize_funct_h5() #448: The changes to the serialize_funct_h5 function's signature to include a resource_dict parameter relate to the main PR's updates that enhance the documentation around resource management.
  • Use resource dict for internal communication #455: The introduction of a resource_dict for internal communication in this PR aligns with the main PR's focus on improving documentation regarding resource management and usage.
  • Add flux executor shutdown #479: The changes in the notebook examples to streamline the usage of the Executor class relate to the main PR's updates that enhance documentation clarity and usability.
  • New examples for the updated documentation #495: The addition of new examples for the updated documentation directly supports the main PR's goal of improving the usability and clarity of the documentation.
  • Change Backend Names #500: The changes to backend names in this PR relate to the main PR's updates in documentation that clarify the usage of the Executor class and its parameters.

🐰 In the land of code, where rabbits hop,
Links to knowledge help us non-stop!
With clearer paths and snippets to share,
Documentation shines, showing we care.
From installation to modes, all is bright,
Hooray for the changes, let's celebrate tonight! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
README.md (1)

26-31: Improve text formatting around hyperlinks

The text formatting around the hyperlinks could be improved for better readability. There are unnecessary spaces and dashes around some links.

Apply this diff:

-submitting each function as individual job to the HPC job scheduler - [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html) - 
+submitting each function as individual job to the HPC job scheduler ([HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html))
-or by requesting a compute allocation of multiple nodes and then distribute the Python functions within this - allocation -
-[HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html). Finally, to accelerate the 
+or by requesting a compute allocation of multiple nodes and then distribute the Python functions within this allocation
+([HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html)). Finally, to accelerate the
-development process executorlib also provides a - [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html) - 
+development process executorlib also provides a [Local Mode](https://executorlib.readthedocs.io/en/latest/1-local.html)
docs/installation.md (3)

36-42: Consider reducing redundant hyperlinks

The hyperlink to [HPC Submission Mode] is repeated in consecutive sentences (lines 38-39). Consider combining these sentences to improve readability while maintaining the same information.

-This is required as in [HPC Submission Mode](https://executorlib.readthedocs.io/en/latest/2-hpc-submission.html) the 
-Python function is stored on the file system until the requested computing resources become available.
+The Python function is stored on the file system until the requested computing resources become available.

71-75: Reduce repetitive references to flux framework

The text mentions "flux framework" with its hyperlink 4 times in 5 lines. Consider restructuring to maintain readability while reducing repetition.

-For optimal performance in [HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html) the
-[flux framework](https://flux-framework.org) is recommended as job scheduler. Even when the [Simple Linux Utility for Resource Management (SLURM)](https://slurm.schedmd.com) 
-or any other job scheduler is already installed on the HPC cluster. [flux framework](https://flux-framework.org) can be
-installed as a secondary job scheduler to leverage [flux framework](https://flux-framework.org) for the distribution of
-resources within a given allocation of the primary scheduler. 
+For optimal performance in [HPC Allocation Mode](https://executorlib.readthedocs.io/en/latest/3-hpc-allocation.html) the
+[flux framework](https://flux-framework.org) is recommended as job scheduler. Even when [SLURM](https://slurm.schedmd.com) 
+or any other job scheduler is already installed on the HPC cluster, flux can be installed as a secondary scheduler to
+leverage its capabilities for resource distribution within a given allocation of the primary scheduler.

77-81: Enhance clarity and add documentation links

Consider improving the technical explanation and adding relevant documentation links:

  1. Add hyperlinks to libhwloc and pmi documentation
  2. Clarify the relationship between MPI implementation and PMI compatibility
-The [flux framework](https://flux-framework.org) uses `libhwloc` and `pmi` to understand the hardware it is running on 
-and to booststrap MPI. `libhwloc` not only assigns CPU cores but also GPUs. This requires `libhwloc` to be compiled with
-support for GPUs from your vendor. In the same way the version of `pmi` for your queuing system has to be compatible
-with the version installed via conda. As `pmi` is typically distributed with the implementation of the Message Passing
-Interface (MPI), it is required to install the compatible MPI library in your conda environment as well. 
+The [flux framework](https://flux-framework.org) uses [libhwloc](https://www.open-mpi.org/projects/hwloc/) for hardware
+topology discovery and [PMI](https://www.mpich.org/documentation/guides/pmi/) for MPI bootstrapping. While libhwloc handles
+both CPU cores and GPU assignments, it requires vendor-specific GPU support during compilation. Similarly, the PMI version
+must be compatible between your queuing system and conda installation. Since PMI typically comes with your MPI
+implementation, you'll need to install the corresponding MPI library in your conda environment.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6adbf5f and 343bd98.

📒 Files selected for processing (2)
  • README.md (4 hunks)
  • docs/installation.md (2 hunks)
🧰 Additional context used
🪛 Markdownlint
README.md

64-64: null
Bare URL used

(MD034, no-bare-urls)

🪛 LanguageTool
README.md

[duplication] ~139-~139: Possible typo: you repeated a word
Context: ...o/en/latest/3-hpc-allocation.html) * SLURM * [SLURM with Flux](https://executorlib.readthed...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~140-~140: Possible typo: you repeated a word
Context: ...-allocation.html#slurm) * SLURM with Flux * [Flux](https://executorlib.readthedocs.io/en/...

(ENGLISH_WORD_REPEAT_RULE)

🔇 Additional comments (1)
README.md (1)

124-154: Documentation structure looks good!

The new documentation structure with detailed sections and proper hyperlinks improves navigation and accessibility. The hierarchy is well-organized and covers all important aspects of the library.

🧰 Tools
🪛 LanguageTool

[duplication] ~139-~139: Possible typo: you repeated a word
Context: ...o/en/latest/3-hpc-allocation.html) * SLURM * [SLURM with Flux](https://executorlib.readthed...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~140-~140: Possible typo: you repeated a word
Context: ...-allocation.html#slurm) * SLURM with Flux * [Flux](https://executorlib.readthedocs.io/en/...

(ENGLISH_WORD_REPEAT_RULE)

@@ -60,8 +61,7 @@ Python function. In addition to the compute cores `cores`, the resource dictiona
as `threads_per_core`, the GPUs per core as `gpus_per_core`, the working directory with `cwd`, the option to use the
OpenMPI oversubscribe feature with `openmpi_oversubscribe` and finally for the [Simple Linux Utility for Resource
Management (SLURM)](https://slurm.schedmd.com) queuing system the option to provide additional command line arguments
with the `slurm_cmd_args` parameter - [resource dictionary]().

with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incomplete URL

There's an incomplete URL that's missing a closing parenthesis.

Apply this diff:

-with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary
+with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary
with the `slurm_cmd_args` parameter - [resource dictionary](https://executorlib.readthedocs.io/en/latest/trouble_shooting.html#resource-dictionary).
🧰 Tools
🪛 Markdownlint

64-64: null
Bare URL used

(MD034, no-bare-urls)

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (11)
docs/trouble_shooting.md (2)

23-25: Consider minor text refinement for better flow.

The links are well-placed and valuable. Consider this minor refinement for better readability:

-Additional features like [caching](https://executorlib.readthedocs.io/en/latest/installation.html#caching), [HPC submission mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-submission-mode) 
-and [HPC allocation mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-allocation-mode) require additional dependencies. The dependencies are explained in more detail in the 
-[installation section](https://executorlib.readthedocs.io/en/latest/installation.html#).
+Additional features such as [caching](https://executorlib.readthedocs.io/en/latest/installation.html#caching), [HPC submission mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-submission-mode), 
+and [HPC allocation mode](https://executorlib.readthedocs.io/en/latest/installation.html#hpc-allocation-mode) require additional dependencies. These dependencies are explained in detail in the 
+[installation section](https://executorlib.readthedocs.io/en/latest/installation.html#).

41-43: Fix typo in parameter description.

The added context and link are helpful. There's a minor typo to fix:

-the resource dictionary parameter `resource_dict` can also include additional parameters define in the submission script
+the resource dictionary parameter `resource_dict` can also include additional parameters defined in the submission script
notebooks/4-developer.ipynb (6)

Line range hint 1-24: Consider enhancing the documentation header

The documentation is well-structured, but consider:

  1. Making the warning about unofficial support more prominent, perhaps in a separate "Warning" or "Note" block
  2. Adding brief explanations for technical terms like "thread based parallelism" and "MPI based parallelism" for developers who might be new to these concepts

Line range hint 47-54: Add error handling to execute_shell_command()

The function should handle subprocess failures gracefully. Consider adding try-except blocks to catch subprocess.CalledProcessError and other potential exceptions.

 def execute_shell_command(
     command: list, universal_newlines: bool = True, shell: bool = False
 ):
     import subprocess
-
-    return subprocess.check_output(
-        command, universal_newlines=universal_newlines, shell=shell
-    )
+    try:
+        return subprocess.check_output(
+            command, universal_newlines=universal_newlines, shell=shell
+        )
+    except subprocess.CalledProcessError as e:
+        raise RuntimeError(f"Command failed with exit status {e.returncode}: {e.output}")
+    except Exception as e:
+        raise RuntimeError(f"Failed to execute command: {str(e)}")

Line range hint 147-157: Enhance process initialization with proper error handling

The init_process() function should handle process creation failures and implement proper resource cleanup.

 def init_process():
     import subprocess
+    import atexit
 
-    return {
-        "process": subprocess.Popen(
-            ["python", "count.py"],
-            stdin=subprocess.PIPE,
-            stdout=subprocess.PIPE,
-            universal_newlines=True,
-            shell=False,
-        )
-    }
+    try:
+        process = subprocess.Popen(
+            ["python", "count.py"],
+            stdin=subprocess.PIPE,
+            stdout=subprocess.PIPE,
+            universal_newlines=True,
+            shell=False,
+        )
+        
+        def cleanup():
+            if process.poll() is None:
+                process.terminate()
+                process.wait(timeout=5)
+        
+        atexit.register(cleanup)
+        return {"process": process}
+    except Exception as e:
+        raise RuntimeError(f"Failed to initialize process: {str(e)}")

Line range hint 176-191: Add timeout mechanism to interact()

The interact() function could potentially hang if the expected output is never received. Consider adding a timeout parameter.

-def interact(shell_input, process, lines_to_read=None, stop_read_pattern=None):
+def interact(shell_input, process, lines_to_read=None, stop_read_pattern=None, timeout=30):
+    import time
+    
+    start_time = time.time()
     process.stdin.write(shell_input)
     process.stdin.flush()
     lines_count = 0
     output = ""
     while True:
+        if time.time() - start_time > timeout:
+            raise TimeoutError("Process interaction timed out")
+            
         output_current = process.stdout.readline()
         output += output_current
         lines_count += 1
         if stop_read_pattern is not None and stop_read_pattern in output_current:
             break
         elif lines_to_read is not None and lines_to_read == lines_count:
             break
     return output

Line range hint 211-214: Enhance shutdown() with verification

The shutdown() function should verify successful process termination and handle hanging processes.

-def shutdown(process):
+def shutdown(process, timeout=5):
     process.stdin.write("shutdown\n")
     process.stdin.flush()
+    try:
+        process.wait(timeout=timeout)
+    except subprocess.TimeoutExpired:
+        process.terminate()
+        try:
+            process.wait(timeout=timeout)
+        except subprocess.TimeoutExpired:
+            process.kill()
+            process.wait()

314-316: Enhance module documentation with version information

Consider adding:

  1. Version requirements for external dependencies (h5py, cloudpickle, etc.)
  2. More specific guidance on which standalone components are considered stable for external use
notebooks/1-local.ipynb (3)

233-233: Fix formatting in markdown text

There's a missing space in "Resource \nManagement".

-Management (SLURM)](https://slurm.schedmd.com)
+Management (SLURM)](https://slurm.schedmd.com)

Line range hint 19-19: Improve error handling specificity

The bare try-except block could be more specific about which exceptions it catches. Consider catching specific exceptions like PermissionError or FileNotFoundError instead of the general OSError.

-    except OSError:
+    except (PermissionError, FileNotFoundError) as e:
+        print(f"Failed to remove cache directory: {e}")

328-328: Comprehensive performance optimization guidance

The documentation provides excellent coverage of performance optimization strategies, including block allocation, caching, and resource management. The warnings about cache usage in production environments are particularly valuable.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 343bd98 and 65ef733.

📒 Files selected for processing (6)
  • docs/development.md (0 hunks)
  • docs/trouble_shooting.md (2 hunks)
  • notebooks/1-local.ipynb (2 hunks)
  • notebooks/2-hpc-submission.ipynb (6 hunks)
  • notebooks/3-hpc-allocation.ipynb (7 hunks)
  • notebooks/4-developer.ipynb (1 hunks)
💤 Files with no reviewable changes (1)
  • docs/development.md
✅ Files skipped from review due to trivial changes (1)
  • notebooks/2-hpc-submission.ipynb
🔇 Additional comments (8)
docs/trouble_shooting.md (1)

19-19: LGTM! Good addition of installation link.

The link to the MPI installation section provides helpful navigation for users seeking setup instructions.

notebooks/3-hpc-allocation.ipynb (6)

9-14: Documentation enhancement looks good!

The added hyperlinks improve navigation and provide clear references to related documentation sections. The links are well-organized and contextually relevant.


25-25: Clear and informative SLURM documentation!

The added explanation about SLURM and flux integration provides valuable context and properly references the documentation.


71-71: Well-documented resource assignment explanation!

The explanation clearly outlines how resource assignment works consistently across different modes, with appropriate links to relevant documentation sections.


125-125: Clear block allocation documentation!

The explanation effectively describes the block allocation functionality and properly references the local mode documentation.


192-192: Well-explained dependencies handling!

The documentation clearly explains how dependencies are handled across different backends, with appropriate reference to the local mode documentation.


234-234: Comprehensive caching documentation!

The explanation effectively describes the caching functionality, includes important performance considerations, and properly references the local mode documentation.

notebooks/1-local.ipynb (1)

Line range hint 1-700: Well-structured and comprehensive code examples

The code examples effectively demonstrate the library's features with a clear progression from basic to advanced concepts. They include proper error handling and resource cleanup.

@jan-janssen jan-janssen merged commit eb8cb29 into main Nov 20, 2024
26 checks passed
@jan-janssen jan-janssen deleted the readme branch November 20, 2024 12:20
This was referenced Nov 20, 2024
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.

1 participant