code-loader 1.0.114__py3-none-any.whl → 1.0.116__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of code-loader might be problematic. Click here for more details.
- code_loader/__init__.py +1 -1
- code_loader/leaploader.py +10 -0
- code_loader/mixpanel_tracker.py +7 -26
- {code_loader-1.0.114.dist-info → code_loader-1.0.116.dist-info}/METADATA +3 -2
- {code_loader-1.0.114.dist-info → code_loader-1.0.116.dist-info}/RECORD +7 -7
- {code_loader-1.0.114.dist-info → code_loader-1.0.116.dist-info}/LICENSE +0 -0
- {code_loader-1.0.114.dist-info → code_loader-1.0.116.dist-info}/WHEEL +0 -0
code_loader/__init__.py
CHANGED
code_loader/leaploader.py
CHANGED
|
@@ -34,6 +34,16 @@ class LeapLoader(LeapLoaderBase):
|
|
|
34
34
|
super().__init__(code_path, code_entry_name)
|
|
35
35
|
|
|
36
36
|
self._preprocess_result_cached = None
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
from code_loader.mixpanel_tracker import track_code_loader_loaded
|
|
40
|
+
track_code_loader_loaded({
|
|
41
|
+
'event_type': 'leap_loader_instantiated',
|
|
42
|
+
'code_path': code_path,
|
|
43
|
+
'code_entry_name': code_entry_name
|
|
44
|
+
})
|
|
45
|
+
except Exception:
|
|
46
|
+
pass
|
|
37
47
|
|
|
38
48
|
@lru_cache()
|
|
39
49
|
def exec_script(self) -> None:
|
code_loader/mixpanel_tracker.py
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Mixpanel tracking utilities for code-loader.
|
|
3
3
|
"""
|
|
4
4
|
import os
|
|
5
|
+
import sys
|
|
5
6
|
import getpass
|
|
6
|
-
from typing import Optional
|
|
7
|
+
from typing import Optional, Dict, Any
|
|
7
8
|
import mixpanel
|
|
8
9
|
|
|
9
10
|
|
|
@@ -11,25 +12,18 @@ class MixpanelTracker:
|
|
|
11
12
|
"""Handles Mixpanel event tracking for code-loader."""
|
|
12
13
|
|
|
13
14
|
def __init__(self, token: str = "f1bf46fb339d8c2930cde8c1acf65491"):
|
|
14
|
-
"""
|
|
15
|
-
Initialize the Mixpanel tracker.
|
|
16
|
-
|
|
17
|
-
Args:
|
|
18
|
-
token: Mixpanel project token
|
|
19
|
-
"""
|
|
20
15
|
self.token = token
|
|
21
16
|
self.mp = mixpanel.Mixpanel(token)
|
|
22
|
-
self._user_id = None
|
|
17
|
+
self._user_id: Optional[str] = None
|
|
23
18
|
|
|
24
19
|
def _get_user_id(self) -> str:
|
|
25
|
-
"""Get the current user ID (whoami)."""
|
|
26
20
|
if self._user_id is None:
|
|
27
21
|
try:
|
|
28
22
|
self._user_id = getpass.getuser()
|
|
29
23
|
except Exception:
|
|
30
24
|
# Fallback to environment variables or default
|
|
31
25
|
self._user_id = os.environ.get('USER', os.environ.get('USERNAME', 'unknown'))
|
|
32
|
-
return self._user_id
|
|
26
|
+
return self._user_id or 'unknown'
|
|
33
27
|
|
|
34
28
|
def _get_tensorleap_user_id(self) -> Optional[str]:
|
|
35
29
|
"""Get the TensorLeap user ID from ~/.tensorleap/user_id if it exists."""
|
|
@@ -62,13 +56,7 @@ class MixpanelTracker:
|
|
|
62
56
|
# Final fallback
|
|
63
57
|
return os.environ.get('USER', os.environ.get('USERNAME', 'unknown'))
|
|
64
58
|
|
|
65
|
-
def track_code_loader_loaded(self, event_properties: Optional[
|
|
66
|
-
"""
|
|
67
|
-
Track when code-loader is loaded.
|
|
68
|
-
|
|
69
|
-
Args:
|
|
70
|
-
event_properties: Additional properties to include with the event
|
|
71
|
-
"""
|
|
59
|
+
def track_code_loader_loaded(self, event_properties: Optional[Dict[str, Any]] = None) -> None:
|
|
72
60
|
try:
|
|
73
61
|
distinct_id = self._get_distinct_id()
|
|
74
62
|
|
|
@@ -77,7 +65,7 @@ class MixpanelTracker:
|
|
|
77
65
|
|
|
78
66
|
properties = {
|
|
79
67
|
'whoami': whoami,
|
|
80
|
-
'python_version': f"{
|
|
68
|
+
'python_version': f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
|
|
81
69
|
'platform': os.name,
|
|
82
70
|
}
|
|
83
71
|
|
|
@@ -97,18 +85,11 @@ _tracker = None
|
|
|
97
85
|
|
|
98
86
|
|
|
99
87
|
def get_tracker() -> MixpanelTracker:
|
|
100
|
-
"""Get the global Mixpanel tracker instance."""
|
|
101
88
|
global _tracker
|
|
102
89
|
if _tracker is None:
|
|
103
90
|
_tracker = MixpanelTracker()
|
|
104
91
|
return _tracker
|
|
105
92
|
|
|
106
93
|
|
|
107
|
-
def track_code_loader_loaded(event_properties: Optional[
|
|
108
|
-
"""
|
|
109
|
-
Convenience function to track code-loader loaded event.
|
|
110
|
-
|
|
111
|
-
Args:
|
|
112
|
-
event_properties: Additional properties to include with the event
|
|
113
|
-
"""
|
|
94
|
+
def track_code_loader_loaded(event_properties: Optional[Dict[str, Any]] = None) -> None:
|
|
114
95
|
get_tracker().track_code_loader_loaded(event_properties)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: code-loader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.116
|
|
4
4
|
Summary:
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: dorhar
|
|
@@ -14,7 +14,8 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Requires-Dist: mixpanel (>=4.10.0,<5.0.0)
|
|
17
|
-
Requires-Dist: numpy (>=1.22.3,<2.0.0)
|
|
17
|
+
Requires-Dist: numpy (>=1.22.3,<2.0.0) ; python_version >= "3.8" and python_version < "3.11"
|
|
18
|
+
Requires-Dist: numpy (>=2.3.2,<3.0.0) ; python_version >= "3.11" and python_version < "3.13"
|
|
18
19
|
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
|
19
20
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
20
21
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
code_loader/__init__.py,sha256=
|
|
1
|
+
code_loader/__init__.py,sha256=outxRQ0M-zMfV0QGVJmAed5qWfRmyD0TV6-goEGAzBw,406
|
|
2
2
|
code_loader/contract/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
code_loader/contract/datasetclasses.py,sha256=gJsXu4zVAaiBlq6GJwPxfTD2e0gICTtI_6Ir61MRL48,8838
|
|
4
4
|
code_loader/contract/enums.py,sha256=GEFkvUMXnCNt-GOoz7NJ9ecQZ2PPDettJNOsxsiM0wk,1622
|
|
@@ -21,16 +21,16 @@ code_loader/experiment_api/workingspace_config_utils.py,sha256=DLzXQCg4dgTV_YgaS
|
|
|
21
21
|
code_loader/inner_leap_binder/__init__.py,sha256=koOlJyMNYzGbEsoIbXathSmQ-L38N_pEXH_HvL7beXU,99
|
|
22
22
|
code_loader/inner_leap_binder/leapbinder.py,sha256=0iHVHxC2NjfH7F0vQFVGy1e0llgKEyUHUHh3DdtqL70,32602
|
|
23
23
|
code_loader/inner_leap_binder/leapbinder_decorators.py,sha256=wjtk3TflrjJ8Y-OeuedVBD-09ZuOjIKGUjL7sMBU0fQ,41017
|
|
24
|
-
code_loader/leaploader.py,sha256=
|
|
24
|
+
code_loader/leaploader.py,sha256=rQRK1lyUPSpZiRs6lKUUxVJBCe3grEY_UxEMxSIpuxI,29709
|
|
25
25
|
code_loader/leaploaderbase.py,sha256=lKdw2pd6H9hFsxVmc7jJMoZd_vlG5He1ooqT-cR_yq8,4496
|
|
26
|
-
code_loader/mixpanel_tracker.py,sha256=
|
|
26
|
+
code_loader/mixpanel_tracker.py,sha256=dxVgMug5sE99DkRonlY-Pg0l1asFH7ZtHZK_fKpk1k0,3089
|
|
27
27
|
code_loader/plot_functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
28
|
code_loader/plot_functions/plot_functions.py,sha256=xg6Gi4myTN9crq6JtyrhYI38HLXjPVJcbnI7CIy8f7w,14625
|
|
29
29
|
code_loader/plot_functions/visualize.py,sha256=gsBAYYkwMh7jIpJeDMPS8G4CW-pxwx6LznoQIvi4vpo,657
|
|
30
30
|
code_loader/utils.py,sha256=_j8b60pimoNAvWMRj7hEkkT6C76qES6cZoBFHpXHMxA,2698
|
|
31
31
|
code_loader/visualizers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
32
|
code_loader/visualizers/default_visualizers.py,sha256=onRnLE_TXfgLN4o52hQIOOhUcFexGlqJ3xSpQDVLuZM,2604
|
|
33
|
-
code_loader-1.0.
|
|
34
|
-
code_loader-1.0.
|
|
35
|
-
code_loader-1.0.
|
|
36
|
-
code_loader-1.0.
|
|
33
|
+
code_loader-1.0.116.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
34
|
+
code_loader-1.0.116.dist-info/METADATA,sha256=WiSm72MyFj2xP8DsMmhBN5IzzHVvYk7YVvE5KZGHs0I,1102
|
|
35
|
+
code_loader-1.0.116.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
36
|
+
code_loader-1.0.116.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|