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 the documentation #333

Merged
merged 6 commits into from
Nov 21, 2024
Merged

Fix the documentation #333

merged 6 commits into from
Nov 21, 2024

Conversation

AntObi
Copy link
Collaborator

@AntObi AntObi commented Nov 21, 2024

Fixing the documentation

Description

This PR fixes the paths in the documentation for the notebooks. It also introduces featurisers as optional dependencies

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test Configuration:

  • Python version: 3.10
  • Operating System: macOS

Reviewers

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Summary by CodeRabbit

  • New Features
    • Updated documentation version to 2.8.0.
    • Introduced a new optional dependency group for featurisers in the project configuration, enhancing material science capabilities.
  • Improvements
    • Enhanced clarity and functionality in multiple Jupyter notebooks, including improved installation commands and updated metadata.
    • Refined examples for generating and analysing chemical compositions, ensuring users have the necessary tools and context.
  • Bug Fixes
    • Adjusted data paths and outputs in notebooks to reflect updated repository structures and improve user experience.

Copy link
Contributor

coderabbitai bot commented Nov 21, 2024

Walkthrough

The pull request introduces updates to the Sphinx documentation configuration and several Jupyter notebooks within the SMACT project. Key changes include incrementing version numbers in docs/conf.py, enhancing tutorial content and installation commands in various notebooks, and updating kernel specifications. Additionally, a new optional dependency group is added to pyproject.toml. These changes collectively aim to improve documentation clarity, functionality, and user experience.

Changes

File Path Change Summary
docs/conf.py Updated version from "2.7" to "2.8", release from "2.7.0" to "2.8.0", and repository_branch from "docs_updates" to "master".
docs/examples/oxidation_states.ipynb Updated import statement to include Lattice, refined species list, clarified print statements, changed structure creation method, and updated kernel specification and Python version.
docs/tutorials/crystal_space.ipynb Enhanced tutorial content, updated package installation command, and modified kernel specification.
docs/tutorials/crystal_space_visualisation.ipynb Streamlined package installation command and updated kernel specification.
docs/tutorials/smact_generation_of_solar_oxides.ipynb Changed installation command to specify a branch and optional features; no changes to core functionality.
docs/tutorials/smact_validity_of_GNoMe.ipynb Enhanced content, modified installation command, adjusted worker count for pandarallel, updated data path, and changed kernel specification and Python version.
pyproject.toml Added new optional dependency group featurisers with dependencies ["matminer", "ElementEmbeddings"].

Possibly related PRs

  • Develop branch updates in preparation for new release #308: The changes in this PR include updates to the docs/conf.py file, specifically incrementing the version from "2.6" to "2.7" and the release from "2.6.0" to "2.7.0", which directly relates to the versioning updates made in the main PR.

Suggested labels

bug, enhancement, docs, dependencies

Poem

In the garden where knowledge blooms,
The docs and notebooks shed their glooms.
With versions fresh and examples bright,
We hop along, in pure delight!
Dependencies added, oh what a treat,
For every learner, a joyful feat! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 347f2ad and 8434325.

📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

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 or @coderabbitai title 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: 5

🧹 Outside diff range and nitpick comments (9)
docs/examples/oxidation_states.ipynb (2)

93-93: Consider enhancing output formatting

The print statements could benefit from improved formatting:

  • Remove the leading space in the f-string
  • Consider adding proper formatting for the probability value (e.g., .2f)
-    f" The probability of Al existing in a 3+ oxidation state with O in a 2- oxidation state is {ox_prob_finder.pair_probability(Al,O)}\"\n",
+    f"The probability of Al existing in a 3+ oxidation state with O in a 2- oxidation state is {ox_prob_finder.pair_probability(Al,O):.2f}"

Also applies to: 102-102


176-183: Enhance documentation for the structure creation example

The CsPbI3 structure creation example would benefit from additional documentation:

  • Add comments explaining the choice of space group
  • Document the significance of the lattice parameter
  • Explain the rationale behind the atomic positions
 # Create the structure
 CsPbI3 = Structure.from_spacegroup(
-'Pm-3m', # Spacegroup for a cubic perovskite
-Lattice.cubic(6.41), # Cubic spacing of 6.41 Å
-['Pb2+', 'Cs+', 'I-'], # Unique species of the ABX3 compound
-[[0.,0.,0.],[0.5,0.5,0.5],[0.,0.,0.5]] # Fractional atomic coordinates of each site
+'Pm-3m',  # Space group Pm-3m (#221) - typical for cubic perovskites
+Lattice.cubic(6.41),  # Experimental lattice parameter of 6.41 Å at room temperature
+['Pb2+', 'Cs+', 'I-'],  # Species in the ABX3 perovskite structure (CsPbI3)
+[[0.,0.,0.],  # Pb at corner (0,0,0)
+ [0.5,0.5,0.5],  # Cs at body centre (1/2,1/2,1/2)
+ [0.,0.,0.5]]  # I at face centres (0,0,1/2), (0,1/2,0), (1/2,0,0)
docs/tutorials/crystal_space.ipynb (1)

79-79: Consider using a specific version tag instead of master

Whilst the installation command correctly includes the crystal_space feature, using the master branch may lead to reproducibility issues as the codebase evolves. Consider pinning to a specific version tag.

-    !pip install "smact[crystal_space] @ git+https://github.com/WMD-group/SMACT.git@master" --quiet
+    !pip install "smact[crystal_space] @ git+https://github.com/WMD-group/SMACT.git@v2.3.0" --quiet
docs/tutorials/crystal_space_visualisation.ipynb (1)

68-68: Consider using PyPI installation for production tutorials

The current installation command uses a direct git repository URL, which is suitable for development but may not be ideal for production tutorials. Consider using PyPI once the changes are released:

-    !pip install "smact[crystal_space] @ git+https://github.com/WMD-group/SMACT.git@master" --quiet
+    !pip install "smact[crystal_space]" --quiet

Additionally, installing from the master branch could expose users to unstable changes. Consider using a specific release tag or commit hash for better reproducibility.

docs/tutorials/smact_generation_of_solar_oxides.ipynb (3)

Line range hint 1-24: Consider adding environment setup instructions

The notebook begins with prerequisites but doesn't specify Python version requirements or environment setup steps. Given that the PR was tested with Python 3.10, this information would be valuable for users.

Add the following markdown cell after the prerequisites section:

### Environment Setup
This notebook has been tested with Python 3.10 on macOS. To set up your environment:

1. Create a new virtual environment:
   ```bash
   python -m venv smact_env
   source smact_env/bin/activate  # On Windows: smact_env\Scripts\activate
  1. Install the required packages:
    pip install "smact[featurisers]"

---

Line range hint `229-272`: **Add error handling for multiprocessing operations**

The `process_element_combinations` function could benefit from error handling to manage potential exceptions during parallel processing.

Consider updating the function with this implementation:

```diff
 def process_element_combinations(all_el_combos):
     """
     Process all element combinations using multiprocessing.
 
     This function applies the smact_filter to all element combinations
     using a multiprocessing pool to improve performance.
 
     Args:
         all_el_combos (iterable): An iterable of element combinations.
 
     Returns:
         list: A flattened list of all compounds that pass the SMACT criteria.
+    
+    Raises:
+        RuntimeError: If parallel processing encounters an error.
     """
-    with multiprocessing.Pool() as p:
-        # Apply smact_filter to all element combinations in parallel
-        result = p.map(smact_filter, all_el_combos)
+    try:
+        with multiprocessing.Pool() as p:
+            # Apply smact_filter to all element combinations in parallel
+            result = p.map(smact_filter, all_el_combos)
+    except Exception as e:
+        raise RuntimeError(f"Error during parallel processing: {str(e)}")
 
     # Flatten the list of results
     flat_list = [item for sublist in result for item in sublist]
     return flat_list

Line range hint 334-394: Consider memory optimisation for large datasets

The add_descriptors function processes over a million rows, which could lead to memory issues. Consider implementing batch processing.

Here's a suggested approach:

  1. Process the data in chunks:
def add_descriptors_in_batches(data, batch_size=10000):
    """
    Process the data in batches to manage memory usage.
    
    Args:
        data (pd.DataFrame): Input DataFrame
        batch_size (int): Number of rows to process at once
        
    Returns:
        pd.DataFrame: Processed DataFrame
    """
    results = []
    for i in range(0, len(data), batch_size):
        batch = data.iloc[i:i+batch_size].copy()
        processed_batch = add_descriptors(batch)
        results.append(processed_batch)
        
    return pd.concat(results, ignore_index=True)
  1. Update the notebook to use this function:
# Apply the function to add descriptors in batches
new_data = add_descriptors_in_batches(new_data)
docs/tutorials/smact_validity_of_GNoMe.ipynb (2)

209-209: Consider using a more robust data path structure

The current data path uses an explicit Git reference which might be unnecessary. Consider:

  1. Using a versioned data path
  2. Adding error handling for data loading
-data_path = "https://raw.githubusercontent.com/WMD-group/SMACT/refs/heads/master/docs/tutorials/stable_materials_hull.csv"
+data_path = "https://raw.githubusercontent.com/WMD-group/SMACT/master/docs/tutorials/stable_materials_hull.csv"
+
+def load_data(url):
+    try:
+        return pd.read_csv(url)
+    except Exception as e:
+        print(f"Error loading data: {e}")
+        return None
+
+df = load_data(data_path)
+if df is None:
+    raise SystemExit("Failed to load required data")

240-245: Enhance visualization with better configuration and error handling

The visualization uses hardcoded values and lacks error handling. Consider extracting plot configuration and adding try-catch blocks.

+# Plot configuration
+PLOT_CONFIG = {
+    'figsize': (8, 6),
+    'title': 'GNoME analysis',
+    'xlabel': 'Number of materials',
+    'rotation': 45,
+    'margin': 1.1  # Right margin multiplier
+}
+
+def create_comparison_plot(df, config=PLOT_CONFIG):
+    try:
+        bar_labels = ["GNoME stable materials", "GNoME - SMACT valid"]
+        counts = [len(df), df["smact_valid"].sum()]
+        
+        fig, ax = plt.subplots(figsize=config['figsize'])
+        bars = ax.barh(bar_labels, counts)
+        ax.bar_label(bars)
+        ax.set_xlabel(config['xlabel'])
+        ax.set_title(config['title'])
+        plt.xticks(rotation=config['rotation'])
+        ax.set_xlim(right=max(counts) * config['margin'])
+        plt.tight_layout()
+        return fig
+    except Exception as e:
+        print(f"Error creating plot: {e}")
+        return None
+
+fig = create_comparison_plot(df)
+if fig:
+    plt.show()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ce807e1 and 347f2ad.

📒 Files selected for processing (7)
  • docs/conf.py (2 hunks)
  • docs/examples/oxidation_states.ipynb (6 hunks)
  • docs/tutorials/crystal_space.ipynb (2 hunks)
  • docs/tutorials/crystal_space_visualisation.ipynb (2 hunks)
  • docs/tutorials/smact_generation_of_solar_oxides.ipynb (1 hunks)
  • docs/tutorials/smact_validity_of_GNoMe.ipynb (6 hunks)
  • pyproject.toml (1 hunks)
🔇 Additional comments (7)
docs/examples/oxidation_states.ipynb (2)

20-20: LGTM: Import statement properly updated

The addition of Lattice import is well-aligned with its subsequent usage in the structure creation example.


61-61: Verify completeness of species list

Please ensure that this refined list of species includes all necessary elements for the tutorial examples.

✅ Verification successful

Species list is complete and correctly represents the oxidation states model

The list shown in the notebook is complete and appropriate for the tutorial. It represents the default probability table used by the Oxidation_state_probability_finder class, and the examples in the notebook (Al³⁺/O²⁻, CaAl₂O₄, and CsPbI₃) all use species that are present in this list. Specifically:

  • Al³⁺ is present as 'Al3'
  • O²⁻ is present as 'O-2'
  • Ca²⁺ is present as 'Ca2'
  • Cs⁺ is present as 'Cs1'
  • Pb²⁺ is present as 'Pb2'
  • I⁻ is present as 'I-1'
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all species used in examples are present in the list
# Search for Species instantiations in the notebook
rg "Species\([\"'](\w+)" docs/examples/oxidation_states.ipynb

Length of output: 65


Script:

#!/bin/bash
# Let's examine the notebook content to understand the context and usage of species
cat docs/examples/oxidation_states.ipynb

Length of output: 7311

pyproject.toml (1)

84-87: Verify the integration of new optional dependencies.

Let's ensure the codebase properly handles these optional dependencies.

✅ Verification successful

Optional dependencies appear to be minimally integrated

The codebase shows very limited usage of these optional dependencies:

  • Only one reference to ElementEmbeddings found as an adaptation comment in smact/utils/composition.py
  • No direct imports or usage of matminer found
  • Both packages are listed only in pyproject.toml as optional featurisers

The minimal integration suggests these are truly optional dependencies that don't require additional documentation updates or test coverage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for imports and usage of matminer and ElementEmbeddings

# Check for imports
echo "Checking for matminer imports..."
rg "^from matminer|^import matminer" -l

echo "Checking for ElementEmbeddings imports..."
rg "^from ElementEmbeddings|^import ElementEmbeddings" -l

# Check for installation instructions in documentation
echo "Checking for installation instructions..."
rg -i "pip install|poetry add|conda install" docs/

# Check for related test files
echo "Checking for related test files..."
fd -g "*test*.py" | xargs rg "matminer|ElementEmbeddings"

Length of output: 1937


Script:

#!/bin/bash
# Let's try a broader search for these dependencies and their usage

# Search for any mention of matminer in Python files
echo "Searching for matminer usage..."
rg "matminer" -t py

# Search for ElementEmbeddings usage
echo "Searching for ElementEmbeddings usage..."
rg "ElementEmbeddings" -t py

# Check setup files for dependency configurations
echo "Checking setup files..."
rg "matminer|ElementEmbeddings" setup.py setup.cfg pyproject.toml

# Check if there are any featuriser-related files
echo "Checking for featuriser files..."
fd -t f "featur" -X cat {}

Length of output: 671

docs/tutorials/crystal_space_visualisation.ipynb (1)

368-368: Verify kernel availability in documentation build environment

The kernel specification has been updated to "smact_dev", which aligns with the PR's documentation fixes. However, we should ensure this kernel is available in the documentation build environment.

✅ Verification successful

Kernel specification is consistent with installation methods

The kernel name "smact_dev" appears consistently across multiple documentation notebooks, and the repository provides clear installation instructions via both pip and conda-forge. Since the documentation can be built using either installation method, and the kernel name is consistently used across the documentation, this change is appropriate.

  • The kernel specification appears in multiple documentation files:
    • docs/tutorials/crystal_space_visualisation.ipynb
    • docs/tutorials/smact_validity_of_GNoMe.ipynb
    • docs/examples/oxidation_states.ipynb
    • docs/examples/valence_electron_count.ipynb
    • docs/tutorials/crystal_space.ipynb
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if kernel setup instructions exist in the repository

# Look for kernel setup instructions in documentation
rg -i "kernel.*setup|setup.*kernel|smact_dev" docs/

Length of output: 422


Script:

#!/bin/bash
# Check for environment setup or installation instructions
rg -i "environment|install|conda|pip" docs/README.md docs/contributing.md docs/installation.md docs/setup.md 2>/dev/null

# Check root README for environment setup
cat README.md

Length of output: 12569

docs/conf.py (2)

174-174: Verify repository branch configuration

The repository branch has been changed from "docs_updates" to "master". Let's verify this is the primary branch.

✅ Verification successful

Repository branch configuration is correctly set to "master"

The configuration value "master" in docs/conf.py aligns with the repository's default branch, which has been confirmed to be "master".

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the primary branch name
# Expected: Confirm if "master" is indeed the main branch

# Check default branch name
gh api repos/WMD-group/SMACT --jq '.default_branch'

Length of output: 58


74-74: Verify version consistency across project files

The version bump from 2.7.0 to 2.8.0 aligns with the breaking changes mentioned in the PR. However, we should ensure this version matches other project files.

Also applies to: 76-76

✅ Verification successful

Version numbers are consistent across project files

The version numbers are properly aligned across the codebase:

  • pyproject.toml: version = "2.8"
  • docs/conf.py: version = "2.8" and release = "2.8.0"

The version bump from 2.7 to 2.8 is consistently reflected in all relevant configuration files, properly documenting the breaking changes in this release.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check version consistency across project files
# Expected: Version "2.8.0" in pyproject.toml and other version files

# Check version in pyproject.toml
echo "Version in pyproject.toml:"
rg -A 1 'version\s*=' pyproject.toml

# Check version in other common version files
echo -e "\nVersion in other files:"
fd -t f -e py -e txt -e ini "version" | xargs rg -l 'version\s*=\s*["\']2\.8'

Length of output: 416


Script:

#!/bin/bash
# Let's try a different approach to check version consistency

# Check version in pyproject.toml without regex
echo "Version in pyproject.toml:"
cat pyproject.toml | grep -A 1 "version ="

# Check version in conf.py
echo -e "\nVersion in docs/conf.py:"
cat docs/conf.py | grep -A 1 "version ="

# Check release in docs/conf.py
echo -e "\nRelease in docs/conf.py:"
cat docs/conf.py | grep -A 1 "release ="

# Look for any other version files
echo -e "\nOther version-related files:"
fd "version|VERSION"

Length of output: 642

docs/tutorials/smact_validity_of_GNoMe.ipynb (1)

Line range hint 412-426: Verify compatibility with the new Python version

The kernel has been updated to use Python 3.10.14 in a dedicated "smact_dev" environment. While this is a good practice for development isolation, we should ensure all dependencies support Python 3.10.

✅ Verification successful

Python 3.10 upgrade is compatible with project dependencies

The kernel update to Python 3.10.14 is fully compatible with the project's dependencies:

  • The project explicitly requires Python >=3.10 in setup.py
  • All requirements files are compiled with Python 3.10
  • Core dependencies like numpy, pandas, scipy, and pymatgen have Python 3.10 support
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if dependencies in requirements or setup files specify Python version constraints

# Search for Python version specifications in requirements files
fd -e txt -e in requirements | xargs grep -l "python"

# Search for Python version specifications in setup files
rg "python_requires" -A 5

Length of output: 212


Script:

#!/bin/bash
# Check content of requirements files and Python version specifications
echo "=== docs/requirements.txt ==="
cat docs/requirements.txt
echo -e "\n=== requirements/requirements-py310.txt ==="
cat requirements/requirements-py310.txt
echo -e "\n=== requirements.txt ==="
cat requirements.txt

Length of output: 9144

"\n",
"print(f\"\\nThe compound probability for CsPbI3 is {prob_compound}.\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.13 ('smact_tests')",
"display_name": "smact_dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Inconsistent kernel configurations require standardisation

The notebooks in the codebase show significant inconsistencies:

  • Multiple kernel names in use: "Python 3 (ipykernel)", "venv", "smact_dev"
  • Various Python versions: 3.9.16, 3.10.14, 3.12.4

This mixed configuration could lead to reproducibility issues. Please:

  • Standardise the kernel name across all notebooks
  • Align Python versions to ensure consistent behaviour
  • Update environment setup documentation to reflect the chosen configuration
🔗 Analysis chain

Verify kernel compatibility

The notebook now uses the "smact_dev" kernel with Python 3.10.14. Please ensure:

  • The kernel name matches the development environment setup
  • All dependencies are compatible with Python 3.10.14

Also applies to: 211-211

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for kernel consistency across notebooks
# Search for kernel specifications in all notebooks
find docs -name "*.ipynb" -exec jq -r '.metadata.kernelspec.display_name' {} \;

Length of output: 277


Script:

#!/bin/bash
# Check Python version specifications in notebooks
find docs -name "*.ipynb" -exec jq -r '.metadata.language_info.version // empty' {} \;

Length of output: 194

@@ -246,7 +245,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "smact_dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Documentation needed for Jupyter notebook environment setup

The smact_dev kernel is used across multiple notebook files but there's no documentation about setting up the Jupyter environment or creating this specific kernel. While the README covers basic installation via pip and conda, it lacks instructions for notebook users.

  • Add documentation for setting up the Jupyter environment with the smact_dev kernel
  • Consider adding this information to the README.md or creating a dedicated notebook setup guide in the docs directory
🔗 Analysis chain

Verify smact_dev kernel documentation

The kernel specification has been changed to smact_dev. Please ensure this kernel is properly documented in the project's setup instructions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for documentation about smact_dev kernel setup
rg -i "smact_dev|kernel setup|jupyter setup" docs/

Length of output: 421


Script:

#!/bin/bash
# Search for installation or environment setup documentation
rg -i "installation|setup|environment|conda|pip" README.md docs/README.md

# Check if there's a dedicated environment setup file
fd -e yml -e yaml "environment|setup"

# Look for any documentation about Jupyter setup
fd -g "*CONTRIBUTING*" -g "*DEVELOP*" -g "*README*" -X rg -i "jupyter|kernel|notebook"

Length of output: 1753

Comment on lines +84 to +87
featurisers = [
"matminer",
"ElementEmbeddings",
]
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider consolidating duplicate dependencies and adding version constraints.

The new featurisers group includes ElementEmbeddings which is already present in the crystal_space group. Additionally, the dependencies lack version constraints which could lead to reproducibility issues.

Consider applying these changes:

 featurisers = [
-    "matminer",
-    "ElementEmbeddings",
+    "matminer>=2024.2.20",
+    "ElementEmbeddings>=0.1.0",  # Specify appropriate version
 ]

Also, consider consolidating the ElementEmbeddings dependency into a shared group to avoid duplication with crystal_space.

Committable suggestion skipped: line range outside the PR's diff.

@@ -39,8 +39,7 @@
" IN_COLAB = False\n",
"\n",
"if IN_COLAB:\n",
" !pip install git+https://github.com/WMD-group/SMACT.git --quiet\n",
" !pip install smact pandas pymatgen matminer"
" !pip install \"smact[featurisers] @ git+https://github.com/WMD-group/SMACT.git@documentation_fix\" --quiet\n"
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

Avoid referencing specific branches in installation commands

The installation command references the documentation_fix branch, which may become invalid once the PR is merged. Consider updating it to use the main/master branch or a specific version tag.

Apply this diff to make the installation command more maintainable:

-    !pip install "smact[featurisers] @ git+https://github.com/WMD-group/SMACT.git@documentation_fix" --quiet
+    !pip install "smact[featurisers]" --quiet

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +63 to +64
"INFO: Pandarallel will run on 12 workers.\n",
"INFO: Pandarallel will use standard multiprocessing data transfer (pipe) to transfer data between the main process and workers.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add explicit worker configuration for better resource control

The parallel processing configuration shows increased workers (12), but this is implicitly determined. Consider explicitly setting the number of workers based on system resources.

-pandarallel.initialize(progress_bar=True)
+# Set number of workers based on system resources
+import multiprocessing
+n_workers = min(12, multiprocessing.cpu_count())
+pandarallel.initialize(progress_bar=True, nb_workers=n_workers)

Committable suggestion skipped: line range outside the PR's diff.

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.46%. Comparing base (1bac2b1) to head (8434325).
Report is 139 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #333      +/-   ##
==========================================
+ Coverage   73.74%   76.46%   +2.72%     
==========================================
  Files          31       31              
  Lines        2544     2545       +1     
==========================================
+ Hits         1876     1946      +70     
+ Misses        668      599      -69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AntObi AntObi merged commit ba5e986 into master Nov 21, 2024
13 checks passed
@AntObi AntObi deleted the documentation_fix branch November 21, 2024 17:10
@AntObi AntObi restored the documentation_fix branch November 21, 2024 23:30
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