cjapy 0.2.3.post2__tar.gz → 0.2.3.post3__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.
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/PKG-INFO +1 -1
- cjapy-0.2.3.post3/cjapy/__version__.py +1 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/cjapy.py +5 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/connector.py +2 -3
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/requestCreator.py +34 -14
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy.egg-info/PKG-INFO +1 -1
- cjapy-0.2.3.post2/cjapy/__version__.py +0 -1
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/LICENSE +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/README.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/__init__.py +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/config.py +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/configs.py +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/projects.py +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/token_provider.py +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy/workspace.py +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy.egg-info/SOURCES.txt +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy.egg-info/dependency_links.txt +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy.egg-info/requires.txt +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/cjapy.egg-info/top_level.txt +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/authenticating_without_config_json.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/cja.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/getting_started.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/logging.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/main.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/projects.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/releases.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/requestCreator.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/docs/workspace.md +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/pyproject.toml +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/requirements.txt +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/setup.cfg +0 -0
- {cjapy-0.2.3.post2 → cjapy-0.2.3.post3}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.3-3"
|
|
@@ -2809,6 +2809,11 @@ class CJA:
|
|
|
2809
2809
|
|
|
2810
2810
|
df.columns = [clean_column_name(col) for col in df.columns]
|
|
2811
2811
|
|
|
2812
|
+
# Rename the last column if binaryTargetMetric is True and targetMetric is provided
|
|
2813
|
+
if binaryTargetMetric and targetMetric:
|
|
2814
|
+
# Ensure the last column is renamed
|
|
2815
|
+
df.columns.values[-1] = f"{clean_column_name(targetMetric)}_binary"
|
|
2816
|
+
|
|
2812
2817
|
# Randomize the rows
|
|
2813
2818
|
df_randomized = df.sample(frac=1).reset_index(drop=True)
|
|
2814
2819
|
|
|
@@ -46,13 +46,13 @@ class AdobeRequest:
|
|
|
46
46
|
self.logger = logger
|
|
47
47
|
self.restTime = 30
|
|
48
48
|
self.retry = retry
|
|
49
|
+
self.connectionType = 'oauthV2'
|
|
49
50
|
if self.config["token"] == "" or time.time() > self.config["date_limit"]:
|
|
50
51
|
if self.config["private_key"] is not None or self.config["pathToKey"] is not None:
|
|
51
52
|
self.connectionType = 'jwt'
|
|
52
53
|
token_and_expiry = token_provider.get_jwt_token_and_expiry_for_config(
|
|
53
54
|
config=self.config, verbose=verbose
|
|
54
55
|
)
|
|
55
|
-
|
|
56
56
|
elif self.config["scopes"] is not None:
|
|
57
57
|
self.connectionType = 'oauthV2'
|
|
58
58
|
token_and_expiry = token_provider.get_oauth_token_and_expiry_for_config(
|
|
@@ -81,8 +81,7 @@ class AdobeRequest:
|
|
|
81
81
|
config=self.config)
|
|
82
82
|
elif self.connectionType == 'oauthV2':
|
|
83
83
|
token_with_expiry = token_provider.get_oauth_token_and_expiry_for_config(
|
|
84
|
-
config=self.config
|
|
85
|
-
connectionType=self.connectionType)
|
|
84
|
+
config=self.config)
|
|
86
85
|
token = token_with_expiry["token"]
|
|
87
86
|
expiry = token_with_expiry["expiry"]
|
|
88
87
|
if self.loggingEnabled:
|
|
@@ -103,6 +103,7 @@ class RequestCreator:
|
|
|
103
103
|
def addMetric(
|
|
104
104
|
self,
|
|
105
105
|
metricId: str = None,
|
|
106
|
+
metricDefinition: dict = None,
|
|
106
107
|
attributionModel: str = None,
|
|
107
108
|
lookbackWindow: Union[int, str] = 30,
|
|
108
109
|
lookbackGranularity: str = "day",
|
|
@@ -111,14 +112,25 @@ class RequestCreator:
|
|
|
111
112
|
"""
|
|
112
113
|
Add a metric to the template.
|
|
113
114
|
Arguments:
|
|
114
|
-
metricId :
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
metricId : OPTIONAL : The metric to add (or the calculated metric ID)
|
|
116
|
+
metricDefinition : OPTIONAL : The definition of an ad-hoc calculated metric
|
|
117
|
+
attributionModel : OPTIONAL : The attribution model to use (e.g., "lastTouch", "firstTouch", "linear", etc.)
|
|
118
|
+
lookbackWindow : OPTIONAL : The lookback window (e.g., number of minutes, hours, days, weeks, etc.)
|
|
119
|
+
lookbackGranularity : OPTIONAL : The granularity of the lookback window (minute, hour, day, week, etc.). Defaults to "day".
|
|
120
|
+
**kwargs : Additional model-specific parameters (e.g., half-life for "timeDecay", weights for "positionBased").
|
|
121
|
+
"""
|
|
122
|
+
if not metricId and not metricDefinition:
|
|
123
|
+
raise ValueError("You must supply either a metricId or a metricDefinition.")
|
|
124
|
+
|
|
125
|
+
if metricId and metricDefinition:
|
|
126
|
+
raise ValueError("You cannot supply both a metricId and a metricDefinition.")
|
|
127
|
+
|
|
128
|
+
# Check if the metricId is a calculated metric (starts with "cm" and contains "@AdobeOrg")
|
|
129
|
+
is_calculated_metric = metricId and metricId.startswith("cm") and "@AdobeOrg" in metricId
|
|
130
|
+
|
|
131
|
+
# Check if attribution model is provided for a calculated metric
|
|
132
|
+
if (is_calculated_metric or metricDefinition is not None) and attributionModel:
|
|
133
|
+
raise ValueError("Attribution is not supported on calculated metrics.")
|
|
122
134
|
|
|
123
135
|
if attributionModel and attributionModel not in ["lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic"]:
|
|
124
136
|
raise ValueError("Invalid attribution model")
|
|
@@ -127,11 +139,19 @@ class RequestCreator:
|
|
|
127
139
|
raise ValueError("Invalid lookbackGranularity. Valid values are: 'minute', 'hour', 'day', 'week', 'month', 'quarter'")
|
|
128
140
|
|
|
129
141
|
columnId = self.__metricCount
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
metric = {"columnId": str(columnId)}
|
|
143
|
+
|
|
144
|
+
if metricId:
|
|
145
|
+
metric["id"] = metricId
|
|
146
|
+
elif metricDefinition:
|
|
147
|
+
if not isinstance(metricDefinition, dict):
|
|
148
|
+
raise ValueError("metricDefinition must be a dictionary")
|
|
149
|
+
metric["id"] = f"ad_hoc_cm_{str(columnId)}"
|
|
150
|
+
metric["metricDefinition"] = metricDefinition
|
|
151
|
+
|
|
132
152
|
# Only add sorting to the first metric if no dimension sort is specified
|
|
133
153
|
if columnId == 0 and "dimensionSort" not in self.__request["settings"]:
|
|
134
|
-
|
|
154
|
+
metric["sort"] = "desc"
|
|
135
155
|
|
|
136
156
|
if attributionModel:
|
|
137
157
|
# Handle sameTouch separately
|
|
@@ -172,7 +192,7 @@ class RequestCreator:
|
|
|
172
192
|
"numPeriods": lookbackWindow
|
|
173
193
|
}
|
|
174
194
|
|
|
175
|
-
|
|
195
|
+
metric["lookback"] = {
|
|
176
196
|
"func": "min-months",
|
|
177
197
|
"granularity": lookbackGranularity,
|
|
178
198
|
"numPeriods": lookbackWindow
|
|
@@ -224,9 +244,9 @@ class RequestCreator:
|
|
|
224
244
|
allocationModel["middleWeight"] = middleWeight
|
|
225
245
|
allocationModel["lastWeight"] = lastWeight
|
|
226
246
|
|
|
227
|
-
|
|
247
|
+
metric["allocationModel"] = allocationModel
|
|
228
248
|
|
|
229
|
-
self.__request["metricContainer"]["metrics"].append(
|
|
249
|
+
self.__request["metricContainer"]["metrics"].append(metric)
|
|
230
250
|
self.__metricCount += 1
|
|
231
251
|
|
|
232
252
|
def getMetrics(self) -> list:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.3-2"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|