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

cd-hit: add osx-arm64 build #52061

Merged
merged 1 commit into from
Nov 12, 2024
Merged

cd-hit: add osx-arm64 build #52061

merged 1 commit into from
Nov 12, 2024

Conversation

mencian
Copy link
Contributor

@mencian mencian commented Nov 12, 2024

Describe your pull request here


Please read the guidelines for Bioconda recipes before opening a pull request (PR).

General instructions

  • If this PR adds or updates a recipe, use "Add" or "Update" appropriately as the first word in its title.
  • New recipes not directly relevant to the biological sciences need to be submitted to the conda-forge channel instead of Bioconda.
  • PRs require reviews prior to being merged. Once your PR is passing tests and ready to be merged, please issue the @BiocondaBot please add label command.
  • Please post questions on Gitter or ping @bioconda/core in a comment.

Instructions for avoiding API, ABI, and CLI breakage issues

Conda is able to record and lock (a.k.a. pin) dependency versions used at build time of other recipes.
This way, one can avoid that expectations of a downstream recipe with regards to API, ABI, or CLI are violated by later changes in the recipe.
If not already present in the meta.yaml, make sure to specify run_exports (see here for the rationale and comprehensive explanation).
Add a run_exports section like this:

build:
  run_exports:
    - ...

with ... being one of:

Case run_exports statement
semantic versioning {{ pin_subpackage("myrecipe", max_pin="x") }}
semantic versioning (0.x.x) {{ pin_subpackage("myrecipe", max_pin="x.x") }}
known breakage in minor versions {{ pin_subpackage("myrecipe", max_pin="x.x") }} (in such a case, please add a note that shortly mentions your evidence for that)
known breakage in patch versions {{ pin_subpackage("myrecipe", max_pin="x.x.x") }} (in such a case, please add a note that shortly mentions your evidence for that)
calendar versioning {{ pin_subpackage("myrecipe", max_pin=None) }}

while replacing "myrecipe" with either name if a name|lower variable is defined in your recipe or with the lowercase name of the package in quotes.

Bot commands for PR management

Please use the following BiocondaBot commands:

Everyone has access to the following BiocondaBot commands, which can be given in a comment:

@BiocondaBot please update Merge the master branch into a PR.
@BiocondaBot please add label Add the please review & merge label.
@BiocondaBot please fetch artifacts Post links to CI-built packages/containers.
You can use this to test packages locally.

Note that the @BiocondaBot please merge command is now depreciated. Please just squash and merge instead.

Also, the bot watches for comments from non-members that include @bioconda/<team> and will automatically re-post them to notify the addressed <team>.

@mencian mencian added the osx-arm64 Related to adding osx-arm64 support label Nov 12, 2024
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several modifications across various files related to the cd-hit package. The build.sh script has been updated to use Bash instead of sh, with enhancements to compiler flags for optimization and a new cleanup step for backup files. The script's installation command has been reformatted for better variable handling. Additionally, multiple Perl scripts have had their shebang lines changed to improve portability, and a new script, OTU_2_taxon_table.pl, has been added to process OTU tables. The meta.yaml file has been updated to reflect a new version (4.8.1), an incremented build number, and modifications to the requirements section. This includes moving certain dependencies and removing others, along with updates to licensing information and additional metadata entries. Overall, these changes aim to enhance the functionality, maintainability, and compatibility of the cd-hit package across different environments.

Possibly related PRs

Suggested labels

please review & merge

Suggested reviewers

  • bgruening
  • druvus

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: 2

🧹 Outside diff range and nitpick comments (4)
recipes/cd-hit/build.sh (2)

1-4: LGTM! Minor spacing improvement suggested.

The switch to bash and early directory creation are good practices. Consider removing the empty line after mkdir for consistency.

 #!/bin/bash
 
 mkdir -p $PREFIX/bin
-

11-13: Add error checking for sed commands.

The Makefile modifications could fail silently if the patterns don't match. Consider adding error checking.

-sed -i.bak 's/^CC =$//g' Makefile
-sed -i.bak 's/^#LDFLAGS.*//g' Makefile
-rm -rf *.bak
+if ! sed -i.bak 's/^CC =$//g' Makefile; then
+    echo "Error: Failed to modify CC in Makefile"
+    exit 1
+fi
+if ! sed -i.bak 's/^#LDFLAGS.*//g' Makefile; then
+    echo "Error: Failed to modify LDFLAGS in Makefile"
+    exit 1
+fi
+rm -f *.bak
recipes/cd-hit/cd-hit.patch (2)

618-776: Well-structured new script with room for improvement

The new OTU_2_taxon_table.pl script is well-documented and includes proper error handling. However, a few improvements could make it even better:

Consider these enhancements:

  1. Add use warnings for better error detection
  2. Extract magic numbers (like array indices 0..6) into named constants
  3. Consider adding input validation for the taxonomy format
 #!/usr/bin/env perl
+use warnings;
 use Getopt::Std;
+
+# Constants for taxonomy levels
+use constant {
+    KINGDOM => 0,
+    PHYLUM  => 1,
+    CLASS   => 2,
+    ORDER   => 3,
+    FAMILY  => 4,
+    GENUS   => 5,
+    SPECIES => 6
+};

475-493: Add error handling for compression steps

While the addition of file compression is good for saving space, consider adding error handling for the compression operations.

Consider adding error checking:

-gzip $SELF/R1.fa &
-gzip $SELF/R2.fa &
+if ! gzip $SELF/R1.fa; then
+    echo "Error compressing R1.fa" >&2
+    exit 1
+fi &
+if ! gzip $SELF/R2.fa; then
+    echo "Error compressing R2.fa" >&2
+    exit 1
+fi &
 wait
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c770a83 and f59af36.

📒 Files selected for processing (3)
  • recipes/cd-hit/build.sh (1 hunks)
  • recipes/cd-hit/cd-hit.patch (1 hunks)
  • recipes/cd-hit/meta.yaml (2 hunks)
🔇 Additional comments (10)
recipes/cd-hit/build.sh (2)

1-28: Verify arm64 compatibility settings.

Since this PR aims to add osx-arm64 support, we should verify that all necessary architecture-specific settings are in place.

#!/bin/bash
# Check for any arm64-specific settings or known issues
echo "Checking for arm64-specific configurations..."
rg -i "arm64|aarch64" --type yaml
rg -i "darwin.*arm|osx.*arm" --type sh

# Check if similar packages have special handling for arm64
echo "Checking other bioconda recipes for arm64 patterns..."
fd "meta.yaml" recipes/ --exec rg -l "osx-arm64"

15-26: ⚠️ Potential issue

Fix compiler variable inconsistency and clarify OpenMP support.

  1. The else branch uses $GXX which seems incorrect - should be $CXX for consistency
  2. The OpenMP comment needs clarification about the status of the fix
 if [[ "$OSTYPE" == "darwin"* ]]; then
-  #Lines below is commented out until fix provided for OPENMP support on OS X for this program
+  # TODO: OpenMP support is currently disabled on macOS due to compatibility issues
+  # Track progress at: <insert issue URL>
  
   CCFLAGS="$CCFLAGS -Wl,-rpath ${PREFIX}/lib -L${PREFIX}/lib -I${PREFIX}/include -fopenmp"
   sed -i.bak 's/CCFLAGS = -fopenmp/CCFLAGS += -fopenmp/g' Makefile
   rm -rf *.bak
   LDFLAGS="$LDFLAGS -stdlib=libc++"
   
   make CC=$CXX openmp=no MAX_SEQ=1000000
 else
-  make CC=$GXX MAX_SEQ=1000000
+  make CC=$CXX MAX_SEQ=1000000
 fi

Let's verify if OpenMP support has been fixed in recent versions:

✅ Verification successful

Let me verify if OpenMP support has been fixed for macOS by checking the build script and related files.


Based on the output, I can now generate the final response:

Update OpenMP configuration comment and fix compiler variable inconsistency

  1. The $GXX variable in the else branch should be $CXX for consistency
  2. The OpenMP comment should be updated to reflect the current status:
 if [[ "$OSTYPE" == "darwin"* ]]; then
-  #Lines below is commented out until fix provided for OPENMP support on OS X for this program
+  # OpenMP is explicitly disabled on macOS due to compatibility issues with clang
+  # llvm-openmp is included as a dependency but not used to ensure stable builds
 
   CCFLAGS="$CCFLAGS -Wl,-rpath ${PREFIX}/lib -L${PREFIX}/lib -I${PREFIX}/include -fopenmp"
   sed -i.bak 's/CCFLAGS = -fopenmp/CCFLAGS += -fopenmp/g' Makefile
   rm -rf *.bak
   LDFLAGS="$LDFLAGS -stdlib=libc++"
   
   make CC=$CXX openmp=no MAX_SEQ=1000000
 else
-  make CC=$GXX MAX_SEQ=1000000
+  make CC=$CXX MAX_SEQ=1000000
 fi

The review comment is correct about the compiler variable inconsistency. The OpenMP situation is intentionally disabled on macOS as evidenced by both the openmp=no flag and the llvm-openmp dependency in meta.yaml. This is a deliberate design choice for stability rather than a pending fix.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any recent commits or issues mentioning OpenMP support for macOS
rg -i "openmp.*darwin|openmp.*osx|openmp.*macos" --type md

Length of output: 216783


Script:

#!/bin/bash
# Check build.sh and related files for OpenMP configuration
rg -i "openmp" recipes/cd-hit/

# Check if there are any patches or configuration files related to OpenMP
fd -e patch -e config recipes/cd-hit/

Length of output: 878

recipes/cd-hit/meta.yaml (6)

15-17: LGTM! Build configuration follows best practices

The build number increment and run_exports pinning are correctly configured to maintain ABI compatibility.


44-45: LGTM! Platform support matches PR objective

The addition of osx-arm64 platform support directly addresses the PR objective.


26-27: LGTM! OpenMP dependencies are correctly configured

The platform-specific OpenMP dependencies are properly set up with correct selectors.


34-40: LGTM! Metadata updates improve package documentation

The metadata updates follow conda-forge standards with proper SPDX license identifier and additional URLs.


46-50: LGTM! Comprehensive identifier additions

The added identifiers improve package discoverability and provide valuable references to publications and tools.


11-12: Verify the patch file existence and contents

The patch file needs to be verified to ensure it's properly placed and contains the expected shebang modifications.

recipes/cd-hit/cd-hit.patch (2)

6-7: Improved portability with env-based shebang lines

The change from direct path (#!/usr/bin/perl) to env-based path (#!/usr/bin/env perl) improves script portability across different systems.

Also applies to: 16-17, 26-27, 36-37, 58-59, 68-69, 78-79, 88-89, 98-99, 108-109, 118-119, 128-129, 138-139, 148-149, 158-159, 168-169, 178-179, 188-189, 198-199, 208-209, 218-219, 228-229, 238-239, 248-249, 258-259, 268-269, 278-279, 288-289, 298-299, 308-309, 318-319, 328-329, 338-339, 348-349, 358-359, 368-369, 378-379, 388-389, 398-399, 417-418, 436-437, 446-447, 456-457, 466-467, 781-782, 915-916, 925-926, 935-936, 945-946, 955-956, 965-966, 978-979


42-49: Good bug fix for handling cd-hit-est-2d output format

The fix properly handles the additional format variations in cd-hit-est-2d output that includes +/- signs. The added comment clearly explains the issue.

mkdir -p $PREFIX/bin
make install PREFIX=$PREFIX/bin

make install PREFIX="$PREFIX/bin"
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 PREFIX path and add error handling.

The PREFIX should point to the root prefix directory, not directly to the bin directory. Also, add error checking for the installation step.

-make install PREFIX="$PREFIX/bin"
+if ! make install PREFIX="$PREFIX"; then
+    echo "Error: Installation failed"
+    exit 1
+fi
📝 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
make install PREFIX="$PREFIX/bin"
if ! make install PREFIX="$PREFIX"; then
echo "Error: Installation failed"
exit 1
fi

Comment on lines +5 to 9
export CFLAGS="${CFLAGS} -O3"
export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include"
export CXXFLAGS="${CXXFLAGS} -O3 -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib"
export CPATH=${PREFIX}/include
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

Improve environment variable handling.

The compiler flags setup looks good, but there are two improvements to consider:

  1. CPATH should be exported like other variables
  2. Variables should be quoted to handle paths with spaces
-export CFLAGS="${CFLAGS} -O3"
-export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include"
-export CXXFLAGS="${CXXFLAGS} -O3 -I$PREFIX/include"
-export LDFLAGS="${LDFLAGS} -L$PREFIX/lib"
-export CPATH=${PREFIX}/include
+export CFLAGS="${CFLAGS} -O3"
+export CPPFLAGS="${CPPFLAGS} -I\"${PREFIX}/include\""
+export CXXFLAGS="${CXXFLAGS} -O3 -I\"${PREFIX}/include\""
+export LDFLAGS="${LDFLAGS} -L\"${PREFIX}/lib\""
+export CPATH="${PREFIX}/include"
📝 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
export CFLAGS="${CFLAGS} -O3"
export CPPFLAGS="${CPPFLAGS} -I$PREFIX/include"
export CXXFLAGS="${CXXFLAGS} -O3 -I$PREFIX/include"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib"
export CPATH=${PREFIX}/include
export CFLAGS="${CFLAGS} -O3"
export CPPFLAGS="${CPPFLAGS} -I\"${PREFIX}/include\""
export CXXFLAGS="${CXXFLAGS} -O3 -I\"${PREFIX}/include\""
export LDFLAGS="${LDFLAGS} -L\"${PREFIX}/lib\""
export CPATH="${PREFIX}/include"

@mencian mencian merged commit dd0d3fa into master Nov 12, 2024
6 checks passed
@mencian mencian deleted the cd-hit branch November 12, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
osx-arm64 Related to adding osx-arm64 support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant