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

adds scikit core to build arrayfire binaries #12

Merged
merged 9 commits into from
Feb 8, 2024

Conversation

syurkevi
Copy link
Contributor

@syurkevi syurkevi commented Feb 1, 2024

No description provided.

@syurkevi syurkevi force-pushed the scikit-core branch 2 times, most recently from 13adc3d to 8594c66 Compare February 2, 2024 09:00
local_paths.extend(sys.path)

module_name = af_module.__name__
for path in local_paths:
Copy link
Collaborator

@roaffix roaffix Feb 4, 2024

Choose a reason for hiding this comment

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

# Its a bad practice to copy multiple times a str variable that can be changed any time. Lets define it once and reuse later
binaries_path = Path(af_module.__name__) / "binaries"

for path in local_paths:
    # Assuming you applied changes in the comments above, we can avoid extra tabulation by exiting the cycle earlier
    if not lpath.exists():
        continue

    files = [x.name for x in binaries_path.glob("*") if x.is_file()]  # can be simplified 'coz binaries_path is already a path
    # It'd be better to bind lib names with their devices/frameworks because likely adding a new backend, e.g., cuda2 will lead to adding afcuda2 or smth
    query_libnames = [f'af{backend.name}' for backend in BackendType] + ['af', 'forge']  # yup, it will also add afunified, but who cares if it will be skipped 🤷 
    found_lib_in_dir = any(lib_name in files for lib_name in query_libnames)  # lets make it O(n) at least

    if not found_lib_in_dir:  # Same as above to avoid extra tabulation
        continue

    if VERBOSE_LOADS:
        print(f"Found binary file by path: {path / binaries_path}")
    
    return path / binaries_path  # returns Path
 
raise RuntimeError("No binaries were found in site path.")

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea, and it's better to make descriptive comments if you catch errors or add implicit verbosing

@syurkevi syurkevi merged commit 17a88c3 into arrayfire:master Feb 8, 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.

2 participants