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

Enhancements to CI Workflows and Python Module Initialization with Minor Fixes #1061

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
70afaf3
Fix GitHub Actions workflow issues
devin-ai-integration[bot] Oct 24, 2024
f48894c
Fix typos in wheel.yml workflow: correct gather-digests job name refe…
devin-ai-integration[bot] Oct 24, 2024
1c9d5ba
docs: update ACL anthology URL to modern format
devin-ai-integration[bot] Oct 24, 2024
8734e76
ci: switch to pull_request_target for better fork PR support
devin-ai-integration[bot] Oct 24, 2024
69fe26f
ci: configure checkout action for pull_request_target
devin-ai-integration[bot] Oct 24, 2024
8b6f03f
ci: update workflow permissions for fork PR execution
devin-ai-integration[bot] Oct 24, 2024
8009ff6
fix: Update checkout action configuration for proper pull_request_tar…
devin-ai-integration[bot] Oct 24, 2024
9e82cc2
fix: Update workflow permissions to allow actions:write
devin-ai-integration[bot] Oct 24, 2024
9861fed
fix: Improve Python wrapper build setup in cmake workflow
devin-ai-integration[bot] Oct 24, 2024
20a26ed
fix: Update job-level permissions in cmake workflow
devin-ai-integration[bot] Oct 24, 2024
c34d059
fix: Split Python wrapper build into platform-specific steps with pro…
devin-ai-integration[bot] Oct 24, 2024
13dac41
fix: Add id-token permission and explicit PR event types to cmake wor…
devin-ai-integration[bot] Oct 24, 2024
e1062eb
ci: Trigger new workflow run with updated permissions
devin-ai-integration[bot] Oct 24, 2024
6dc9aea
docs: Add descriptive comment to cmake workflow
devin-ai-integration[bot] Oct 24, 2024
bdd7253
fix: Move imports to top of __init__.py to prevent circular imports
devin-ai-integration[bot] Oct 24, 2024
accc605
ci: Add concurrency configuration to prevent workflow cancellations
devin-ai-integration[bot] Oct 24, 2024
6b29d4d
ci: Improve workflow configuration to prevent cancellations
devin-ai-integration[bot] Oct 24, 2024
3b47b7a
fix: Add _init.py to handle proper module initialization and prevent …
devin-ai-integration[bot] Oct 24, 2024
48067e9
fix: Update workflow concurrency settings to prevent unnecessary canc…
devin-ai-integration[bot] Oct 24, 2024
cbf7919
fix: Move __version__ import to beginning of pythoncode block to prev…
devin-ai-integration[bot] Oct 24, 2024
286bf5b
Update workflow concurrency settings to prevent unwanted cancellations
devin-ai-integration[bot] Oct 24, 2024
13bb730
fix: Update workflow triggers from pull_request_target to pull_reques…
devin-ai-integration[bot] Oct 24, 2024
be8e57a
fix: Improve workflow configuration to prevent startup failures
devin-ai-integration[bot] Oct 24, 2024
80c8adf
fix: Improve environment variable handling in cmake workflow for Pyth…
devin-ai-integration[bot] Oct 24, 2024
90f9aaa
fix: Update version import mechanism in setup.py to use absolute paths
devin-ai-integration[bot] Oct 24, 2024
fd0467a
fix: Remove redundant permissions and simplify concurrency group in w…
devin-ai-integration[bot] Oct 24, 2024
84a0994
fix: Separate build and test skip patterns in wheel.yml
devin-ai-integration[bot] Oct 24, 2024
dd9b790
ci: Simplify cmake workflow to focus on Ubuntu builds
devin-ai-integration[bot] Oct 24, 2024
8473a92
fix: Resolve circular import by restructuring module initialization s…
devin-ai-integration[bot] Oct 24, 2024
47b0d34
fix: Implement lazy loading for _sentencepiece module to resolve circ…
devin-ai-integration[bot] Oct 24, 2024
8aa9829
fix: Improve module initialization to prevent circular imports
devin-ai-integration[bot] Oct 24, 2024
9b71d86
fix: Add proper SWIG registration order and improve error handling
devin-ai-integration[bot] Oct 24, 2024
279a981
fix: Implement lazy loading and proper registration sequence
devin-ai-integration[bot] Oct 24, 2024
529f314
Merge pull request #1 from kasinadhsarma/devin/fix-workflow-issues/2745
kasinadhsarma Oct 24, 2024
e0aa610
fix: Improve module initialization and registration sequence
devin-ai-integration[bot] Oct 24, 2024
513b766
fix: Improve module initialization and registration sequence
devin-ai-integration[bot] Oct 24, 2024
c160d10
fix: Implement proper lazy loading and initialization for SWIG classes
devin-ai-integration[bot] Oct 24, 2024
f65c814
fix: Improve module initialization and registration sequence
devin-ai-integration[bot] Oct 24, 2024
e836866
fix: Improve module initialization and registration handling
devin-ai-integration[bot] Oct 24, 2024
f696c4f
fix: Improve module initialization and import mechanism
devin-ai-integration[bot] Oct 24, 2024
1d800a8
fix: Add SWIG registration function verification
devin-ai-integration[bot] Oct 24, 2024
42cf801
fix: Improve module initialization and registration sequence
devin-ai-integration[bot] Oct 24, 2024
58eb50e
fix: Improve module initialization to prevent circular imports
devin-ai-integration[bot] Oct 24, 2024
8aac6ba
Merge pull request #2 from kasinadhsarma/devin/fix-workflow-issues/2745
kasinadhsarma Oct 24, 2024
2cfb0ff
fix: Implement robust module loading and registration sequence
devin-ai-integration[bot] Oct 24, 2024
3a525a2
Merge pull request #3 from kasinadhsarma/devin/fix-workflow-issues/2745
kasinadhsarma Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Add proper SWIG registration order and improve error handling
- Register immutable classes before processor classes
- Add explicit error message for module load failures
- Remove silent error handling in _load_sentencepiece
  • Loading branch information
devin-ai-integration[bot] committed Oct 24, 2024
commit 9b71d86bd0d05aa96f07800d8b7a85264ff5a8d1
29 changes: 16 additions & 13 deletions python/src/sentencepiece/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,31 @@
except ImportError:
import __builtin__

# Lazy load _sentencepiece to prevent circular imports
# Load _sentencepiece module
_sentencepiece_module = None
def _load_sentencepiece():
global _sentencepiece_module
if _sentencepiece_module is None:
try:
if __package__ or "." in __name__:
from . import _sentencepiece as _sp
else:
import _sentencepiece as _sp
_sentencepiece_module = _sp
except ImportError:
return None
if __package__ or "." in __name__:
from . import _sentencepiece as _sp
else:
import _sentencepiece as _sp
_sentencepiece_module = _sp
return _sentencepiece_module

# Function to initialize class registrations after all classes are defined
def _initialize_registrations():
_sp = _load_sentencepiece()
if _sp is not None:
_sp.SentencePieceProcessor_swigregister(SentencePieceProcessor)
_sp.SentencePieceTrainer_swigregister(SentencePieceTrainer)
_sp.SentencePieceNormalizer_swigregister(SentencePieceNormalizer)
if not _sp:
raise ImportError("Failed to load _sentencepiece module. Please ensure the module is properly installed.")
# Register immutable classes first
_sp.ImmutableSentencePieceText_ImmutableSentencePiece_swigregister(ImmutableSentencePieceText_ImmutableSentencePiece)
_sp.ImmutableSentencePieceText_swigregister(ImmutableSentencePieceText)
_sp.ImmutableNBestSentencePieceText_swigregister(ImmutableNBestSentencePieceText)
# Register main processor classes
_sp.SentencePieceProcessor_swigregister(SentencePieceProcessor)
_sp.SentencePieceTrainer_swigregister(SentencePieceTrainer)
_sp.SentencePieceNormalizer_swigregister(SentencePieceNormalizer)

def _swig_repr(self):
try:
Expand Down