code-loader 1.0.115__tar.gz → 1.0.117__tar.gz
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-1.0.115 → code_loader-1.0.117}/PKG-INFO +4 -3
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/__init__.py +6 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/leaploader.py +10 -0
- code_loader-1.0.117/code_loader/mixpanel_tracker.py +134 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/pyproject.toml +2 -1
- {code_loader-1.0.115 → code_loader-1.0.117}/LICENSE +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/README.md +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/__init__.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/datasetclasses.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/enums.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/exceptions.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/mapping.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/responsedataclasses.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/contract/visualizer_classes.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/default_losses.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/default_metrics.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/__init__.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/api.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/cli_config_utils.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/client.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/epoch.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/experiment.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/experiment_context.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/types.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/utils.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/workingspace_config_utils.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/inner_leap_binder/__init__.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/inner_leap_binder/leapbinder.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/inner_leap_binder/leapbinder_decorators.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/leaploaderbase.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/plot_functions/__init__.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/plot_functions/plot_functions.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/plot_functions/visualize.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/utils.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/visualizers/__init__.py +0 -0
- {code_loader-1.0.115 → code_loader-1.0.117}/code_loader/visualizers/default_visualizers.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: code-loader
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.117
|
|
4
4
|
Summary:
|
|
5
|
-
Home-page: https://github.com/tensorleap/code-loader
|
|
6
5
|
License: MIT
|
|
7
6
|
Author: dorhar
|
|
8
7
|
Author-email: doron.harnoy@tensorleap.ai
|
|
@@ -14,11 +13,13 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Dist: mixpanel (>=4.10.0,<5.0.0)
|
|
17
17
|
Requires-Dist: numpy (>=1.22.3,<2.0.0) ; python_version >= "3.8" and python_version < "3.11"
|
|
18
18
|
Requires-Dist: numpy (>=2.3.2,<3.0.0) ; python_version >= "3.11" and python_version < "3.13"
|
|
19
19
|
Requires-Dist: psutil (>=5.9.5,<6.0.0)
|
|
20
20
|
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
21
21
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
22
|
+
Project-URL: Homepage, https://github.com/tensorleap/code-loader
|
|
22
23
|
Project-URL: Repository, https://github.com/tensorleap/code-loader
|
|
23
24
|
Description-Content-Type: text/markdown
|
|
24
25
|
|
|
@@ -2,3 +2,9 @@ from code_loader.leaploader import LeapLoader
|
|
|
2
2
|
from code_loader.inner_leap_binder import global_leap_binder as leap_binder
|
|
3
3
|
from code_loader.experiment_api.experiment import init_experiment
|
|
4
4
|
from code_loader.experiment_api.client import Client
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
from code_loader.mixpanel_tracker import track_code_loader_loaded
|
|
8
|
+
track_code_loader_loaded({'event_type': 'module_import'})
|
|
9
|
+
except Exception:
|
|
10
|
+
pass
|
|
@@ -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:
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Mixpanel tracking utilities for code-loader.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import getpass
|
|
7
|
+
import uuid
|
|
8
|
+
from typing import Optional, Dict, Any
|
|
9
|
+
import mixpanel # type: ignore[import]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MixpanelTracker:
|
|
13
|
+
"""Handles Mixpanel event tracking for code-loader."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, token: str = "f1bf46fb339d8c2930cde8c1acf65491"):
|
|
16
|
+
self.token = token
|
|
17
|
+
self.mp = mixpanel.Mixpanel(token)
|
|
18
|
+
self._user_id: Optional[str] = None
|
|
19
|
+
|
|
20
|
+
def _get_whoami(self) -> str:
|
|
21
|
+
"""Get the current system username (whoami) for device identification.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
str: The system username, with fallbacks to environment variables or 'unknown'
|
|
25
|
+
"""
|
|
26
|
+
if self._user_id is None:
|
|
27
|
+
try:
|
|
28
|
+
self._user_id = getpass.getuser()
|
|
29
|
+
except Exception:
|
|
30
|
+
# Fallback to environment variables or default
|
|
31
|
+
self._user_id = os.environ.get('USER', os.environ.get('USERNAME', 'unknown'))
|
|
32
|
+
return self._user_id or 'unknown'
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _get_tensorleap_user_id(self) -> Optional[str]:
|
|
36
|
+
"""Get the TensorLeap user ID from ~/.tensorleap/user_id if it exists."""
|
|
37
|
+
try:
|
|
38
|
+
user_id_path = os.path.expanduser("~/.tensorleap/user_id")
|
|
39
|
+
if os.path.exists(user_id_path):
|
|
40
|
+
with open(user_id_path, 'r') as f:
|
|
41
|
+
user_id = f.read().strip()
|
|
42
|
+
if user_id:
|
|
43
|
+
return user_id
|
|
44
|
+
except Exception:
|
|
45
|
+
pass
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
def _get_or_create_device_id(self) -> str:
|
|
49
|
+
"""Get or create a device ID from ~/.tensorleap/device_id file.
|
|
50
|
+
|
|
51
|
+
If the file doesn't exist, creates it with a new UUID.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
str: The device ID (UUID string)
|
|
55
|
+
"""
|
|
56
|
+
try:
|
|
57
|
+
device_id_path = os.path.expanduser("~/.tensorleap/device_id")
|
|
58
|
+
|
|
59
|
+
# Create directory if it doesn't exist
|
|
60
|
+
os.makedirs(os.path.dirname(device_id_path), exist_ok=True)
|
|
61
|
+
|
|
62
|
+
if os.path.exists(device_id_path):
|
|
63
|
+
with open(device_id_path, 'r') as f:
|
|
64
|
+
device_id = f.read().strip()
|
|
65
|
+
if device_id:
|
|
66
|
+
return device_id
|
|
67
|
+
|
|
68
|
+
# Generate new device ID and save it
|
|
69
|
+
device_id = str(uuid.uuid4())
|
|
70
|
+
with open(device_id_path, 'w') as f:
|
|
71
|
+
f.write(device_id)
|
|
72
|
+
|
|
73
|
+
return device_id
|
|
74
|
+
except Exception:
|
|
75
|
+
# Fallback to generating a new UUID if file operations fail
|
|
76
|
+
return str(uuid.uuid4())
|
|
77
|
+
|
|
78
|
+
def _get_distinct_id(self) -> str:
|
|
79
|
+
"""Get the distinct ID for Mixpanel tracking.
|
|
80
|
+
|
|
81
|
+
Priority order:
|
|
82
|
+
1. TensorLeap user ID (from ~/.tensorleap/user_id)
|
|
83
|
+
2. Device ID (from ~/.tensorleap/device_id, generated if not exists)
|
|
84
|
+
"""
|
|
85
|
+
tensorleap_user_id = self._get_tensorleap_user_id()
|
|
86
|
+
if tensorleap_user_id:
|
|
87
|
+
return tensorleap_user_id
|
|
88
|
+
|
|
89
|
+
return self._get_or_create_device_id()
|
|
90
|
+
|
|
91
|
+
def track_code_loader_loaded(self, event_properties: Optional[Dict[str, Any]] = None) -> None:
|
|
92
|
+
"""Track code loader loaded event with device identification.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
event_properties: Optional additional properties to include in the event
|
|
96
|
+
"""
|
|
97
|
+
try:
|
|
98
|
+
distinct_id = self._get_distinct_id()
|
|
99
|
+
|
|
100
|
+
tensorleap_user_id = self._get_tensorleap_user_id()
|
|
101
|
+
whoami = self._get_whoami()
|
|
102
|
+
device_id = self._get_or_create_device_id()
|
|
103
|
+
|
|
104
|
+
properties = {
|
|
105
|
+
'whoami': whoami,
|
|
106
|
+
'$device_id': device_id, # Always use device_id for $device_id
|
|
107
|
+
'python_version': f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
|
|
108
|
+
'platform': os.name,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if tensorleap_user_id:
|
|
112
|
+
properties['user_id'] = tensorleap_user_id
|
|
113
|
+
|
|
114
|
+
if event_properties:
|
|
115
|
+
properties.update(event_properties)
|
|
116
|
+
|
|
117
|
+
self.mp.track(distinct_id, 'code_loader_loaded', properties)
|
|
118
|
+
except Exception as e:
|
|
119
|
+
pass
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# Global tracker instance
|
|
123
|
+
_tracker = None
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def get_tracker() -> MixpanelTracker:
|
|
127
|
+
global _tracker
|
|
128
|
+
if _tracker is None:
|
|
129
|
+
_tracker = MixpanelTracker()
|
|
130
|
+
return _tracker
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def track_code_loader_loaded(event_properties: Optional[Dict[str, Any]] = None) -> None:
|
|
134
|
+
get_tracker().track_code_loader_loaded(event_properties)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "code-loader"
|
|
3
|
-
version = "1.0.
|
|
3
|
+
version = "1.0.117"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = ["dorhar <doron.harnoy@tensorleap.ai>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -20,6 +20,7 @@ numpy = [
|
|
|
20
20
|
psutil = "^5.9.5"
|
|
21
21
|
requests = "^2.32.3"
|
|
22
22
|
pyyaml = "^6.0.2"
|
|
23
|
+
mixpanel = "^4.10.0"
|
|
23
24
|
|
|
24
25
|
[tool.poetry.dev-dependencies]
|
|
25
26
|
pytest = "^7.1.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/experiment_context.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.115 → code_loader-1.0.117}/code_loader/experiment_api/workingspace_config_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_loader-1.0.115 → code_loader-1.0.117}/code_loader/inner_leap_binder/leapbinder_decorators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|