cjapy 0.2.3.post2__tar.gz → 0.2.3.post4__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.
Files changed (32) hide show
  1. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/PKG-INFO +1 -1
  2. cjapy-0.2.3.post4/cjapy/__version__.py +1 -0
  3. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/cjapy.py +22 -14
  4. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/connector.py +2 -3
  5. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/requestCreator.py +34 -14
  6. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/workspace.py +3 -0
  7. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy.egg-info/PKG-INFO +1 -1
  8. cjapy-0.2.3.post2/cjapy/__version__.py +0 -1
  9. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/LICENSE +0 -0
  10. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/README.md +0 -0
  11. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/__init__.py +0 -0
  12. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/config.py +0 -0
  13. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/configs.py +0 -0
  14. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/projects.py +0 -0
  15. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy/token_provider.py +0 -0
  16. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy.egg-info/SOURCES.txt +0 -0
  17. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy.egg-info/dependency_links.txt +0 -0
  18. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy.egg-info/requires.txt +0 -0
  19. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/cjapy.egg-info/top_level.txt +0 -0
  20. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/authenticating_without_config_json.md +0 -0
  21. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/cja.md +0 -0
  22. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/getting_started.md +0 -0
  23. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/logging.md +0 -0
  24. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/main.md +0 -0
  25. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/projects.md +0 -0
  26. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/releases.md +0 -0
  27. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/requestCreator.md +0 -0
  28. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/docs/workspace.md +0 -0
  29. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/pyproject.toml +0 -0
  30. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/requirements.txt +0 -0
  31. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/setup.cfg +0 -0
  32. {cjapy-0.2.3.post2 → cjapy-0.2.3.post4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjapy
3
- Version: 0.2.3.post2
3
+ Version: 0.2.3.post4
4
4
  Summary: Adobe Customer Journey Analytics (CJA) wrapper
5
5
  Home-page: https://github.com/pitchmuc/cjapy
6
6
  Author: Julien Piccini
@@ -0,0 +1 @@
1
+ __version__ = "0.2.3-4"
@@ -720,7 +720,7 @@ class CJA:
720
720
  raise ValueError("Require a Data View ID")
721
721
  if self.loggingEnabled:
722
722
  self.logger.debug(f"getDimensions start")
723
- path = f"/datagroups/data/{dataviewId}/dimensions"
723
+ path = f"/data/dataviews/{dataviewId}/dimensions"
724
724
  params = {"page":0}
725
725
  if full:
726
726
  params[
@@ -764,7 +764,7 @@ class CJA:
764
764
  raise ValueError("Require a Dimension ID")
765
765
  if self.loggingEnabled:
766
766
  self.logger.debug(f"getDimension start, id: {dimensionId}")
767
- path = f"/datagroups/data/{dataviewId}/dimensions/{dimensionId}"
767
+ path = f"/data/dataviews/{dataviewId}/dimensions/{dimensionId}"
768
768
  params = {}
769
769
  if full:
770
770
  params[
@@ -794,7 +794,7 @@ class CJA:
794
794
  raise ValueError("Require a Data View ID")
795
795
  if self.loggingEnabled:
796
796
  self.logger.debug(f"getMetrics start")
797
- path = f"/datagroups/data/{dataviewId}/metrics"
797
+ path = f"/data/dataviews/{dataviewId}/metrics"
798
798
  params = {"page":0}
799
799
  if full:
800
800
  params[
@@ -835,7 +835,7 @@ class CJA:
835
835
  raise ValueError("Require a Dimension ID")
836
836
  if self.loggingEnabled:
837
837
  self.logger.debug(f"getMetric start, id: {metricId}")
838
- path = f"/datagroups/data/{dataviewId}/metrics/{metricId}"
838
+ path = f"/data/dataviews/{dataviewId}/metrics/{metricId}"
839
839
  params = {}
840
840
  if full:
841
841
  params[
@@ -873,7 +873,7 @@ class CJA:
873
873
  """
874
874
  if self.loggingEnabled:
875
875
  self.logger.debug(f"getDataViews start, output: {output}")
876
- path = "/datagroups/dataviews"
876
+ path = "/data/dataviews"
877
877
  params = {
878
878
  "limit": limit,
879
879
  "includeType": includeType,
@@ -921,7 +921,7 @@ class CJA:
921
921
  raise ValueError("dataViewId is required")
922
922
  if self.loggingEnabled:
923
923
  self.logger.debug(f"getDataView start")
924
- path = f"/datagroups/dataviews/{dataViewId}"
924
+ path = f"/data/dataviews/{dataViewId}"
925
925
  params = {}
926
926
  if full:
927
927
  params[
@@ -943,7 +943,7 @@ class CJA:
943
943
  """
944
944
  if self.loggingEnabled:
945
945
  self.logger.debug(f"getConnections start")
946
- path = f"/datagroups/connections"
946
+ path = f"/data/connections"
947
947
  params = {"limit":limit,"page":0}
948
948
  if full:
949
949
  params["expansion"] ="granularBackfills,granularStreaming,backfillsSummaryConnection,name,description,isDeleted,isDisabled,dataSets,createdDate,modified,sandboxName,organization,backfillEnabled,modifiedBy,ownerFullName"
@@ -968,7 +968,7 @@ class CJA:
968
968
  """
969
969
  if connectionId is None:
970
970
  raise ValueError("Require a connection ID")
971
- path = f"/datagroups/connections/{connectionId}"
971
+ path = f"/data/connections/{connectionId}"
972
972
  params = {'expansion':"granularBackfills,granularStreaming,backfillsSummaryConnection,name,description,isDeleted,isDisabled,dataSets,createdDate,modified,sandboxName,organization,backfillEnabled,modifiedBy,ownerFullName"}
973
973
  res = self.connector.getData(self.endpoint + path,params=params, **kwargs)
974
974
  return res
@@ -983,7 +983,7 @@ class CJA:
983
983
  raise ValueError("Require information to be passed for data view creation")
984
984
  if self.loggingEnabled:
985
985
  self.logger.debug(f"validateDataView start")
986
- path = "/datagroups/dataviews/validate"
986
+ path = "/data/dataviews/validate"
987
987
  if ".json" in data:
988
988
  with open(data, "r") as f:
989
989
  data = json.load(f)
@@ -1008,7 +1008,7 @@ class CJA:
1008
1008
  common timezone: US/Montain, US/Pacific, US/Michigan, US/Central, Europe/London, Europe/Paris, Asia/Tokyo, Australia/Sydney
1009
1009
  minuteInactivity : OPTIONAL : number of minutes of inactivity before closing a session
1010
1010
  """
1011
- path = "/datagroups/dataviews/"
1011
+ path = "/data/dataviews/"
1012
1012
  if data is None and name is None and connectionId is None:
1013
1013
  raise ValueError("Require information to be passed for data view creation")
1014
1014
  if data is not None:
@@ -1053,7 +1053,7 @@ class CJA:
1053
1053
  raise ValueError("Require a data view ID")
1054
1054
  if self.loggingEnabled:
1055
1055
  self.logger.debug(f"deleteDataView start, id: {dataViewId}")
1056
- path = f"/datagroups/dataviews/{dataViewId}"
1056
+ path = f"/data/dataviews/{dataViewId}"
1057
1057
  res = self.connector.deleteData(self.endpoint + path)
1058
1058
  return res
1059
1059
 
@@ -1074,7 +1074,7 @@ class CJA:
1074
1074
  raise ValueError("Require data to be passed for the update")
1075
1075
  if self.loggingEnabled:
1076
1076
  self.logger.debug(f"updateDataView start, id: {dataViewId}")
1077
- path = f"/datagroups/dataviews/{dataViewId}"
1077
+ path = f"/data/dataviews/{dataViewId}"
1078
1078
  if ".json" in data:
1079
1079
  with open(data, "r", encoding=kwargs.get("encoding", "utf-8")) as f:
1080
1080
  data = json.load(f.read())
@@ -1091,7 +1091,7 @@ class CJA:
1091
1091
  raise ValueError("Require a data view ID")
1092
1092
  if self.loggingEnabled:
1093
1093
  self.logger.debug(f"copyDataView start, id: {dataViewId}")
1094
- path = f"/datagroups/dataviews/copy/{dataViewId}"
1094
+ path = f"/data/dataviews/copy/{dataViewId}"
1095
1095
  res = self.connector.putData(self.endpoint + path, **kwargs)
1096
1096
  return res
1097
1097
 
@@ -2051,7 +2051,7 @@ class CJA:
2051
2051
  segmentApplied[obj["id"]] = obj["dateRange"]
2052
2052
  ### table columnIds and StaticRow IDs
2053
2053
  tableColumnIds = {
2054
- obj["columnId"]: obj["filters"][0]
2054
+ obj["columnId"]: obj.get("filters",[])[0]
2055
2055
  for obj in dataRequest["metricContainer"]["metrics"]
2056
2056
  }
2057
2057
  ### create relations for metrics with Filter on top
@@ -2176,6 +2176,7 @@ class CJA:
2176
2176
  dataRows = res.get("rows")
2177
2177
  columns = res.get("columns")
2178
2178
  summaryData = res.get("summaryData")
2179
+ resultsTruncated = res.get("resultsTruncated")
2179
2180
  totalElements = res.get("numberOfElements")
2180
2181
  lastPage = res.get("lastPage", True)
2181
2182
  if float(len(dataRows)) >= float(n_results):
@@ -2237,6 +2238,7 @@ class CJA:
2237
2238
  self.logger.debug(f"reportType: {reportType}")
2238
2239
  columns = None ## no "columns" key in response
2239
2240
  summaryData = res.get("summaryData")
2241
+ resultsTruncated = res.get("resultsTruncated")
2240
2242
  (
2241
2243
  nb_columns,
2242
2244
  tableColumnIds,
@@ -2279,6 +2281,7 @@ class CJA:
2279
2281
  dataRequest=dataRequest,
2280
2282
  columns=columns,
2281
2283
  summaryData=summaryData,
2284
+ resultsTruncated=resultsTruncated,
2282
2285
  cjaConnector=self,
2283
2286
  reportType=reportType,
2284
2287
  metrics=metricColumns, ## for normal type ## for staticReport
@@ -2809,6 +2812,11 @@ class CJA:
2809
2812
 
2810
2813
  df.columns = [clean_column_name(col) for col in df.columns]
2811
2814
 
2815
+ # Rename the last column if binaryTargetMetric is True and targetMetric is provided
2816
+ if binaryTargetMetric and targetMetric:
2817
+ # Ensure the last column is renamed
2818
+ df.columns.values[-1] = f"{clean_column_name(targetMetric)}_binary"
2819
+
2812
2820
  # Randomize the rows
2813
2821
  df_randomized = df.sample(frac=1).reset_index(drop=True)
2814
2822
 
@@ -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 : REQUIRED : The metric to add
115
- attributionModel : OPTIONAL : The attribution model to use (e.g., "lastTouch", "firstTouch", "linear", "participation", "sameTouch", "uShaped", "jShaped", "reverseJShaped", "timeDecay", "positionBased", "algorithmic")
116
- lookbackWindow : OPTIONAL : The lookback window (number of minutes, hours, days, weeks, months, quarters, "session", or "person"). Assumes 30 if not specified.
117
- lookbackGranularity : OPTIONAL : The granularity of the lookback window (minute, hour, day, week, month, quarter). Defaults to "day".
118
- **kwargs : Additional model-specific parameters. For "timeDecay" (assumes 1 week): halfLifeNumPeriods, halfLifeGranularity, for "positionBased": firstWeight, middleWeight, lastWeight.
119
- """
120
- if metricId is None:
121
- raise ValueError("Require a metric ID")
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
- addMetric = {"columnId": str(columnId), "id": metricId}
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
- addMetric["sort"] = "desc"
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
- addMetric["lookback"] = {
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
- addMetric["allocationModel"] = allocationModel
247
+ metric["allocationModel"] = allocationModel
228
248
 
229
- self.__request["metricContainer"]["metrics"].append(addMetric)
249
+ self.__request["metricContainer"]["metrics"].append(metric)
230
250
  self.__metricCount += 1
231
251
 
232
252
  def getMetrics(self) -> list:
@@ -21,6 +21,7 @@ class Workspace:
21
21
  dataRequest: dict = None,
22
22
  columns: dict = None,
23
23
  summaryData: dict = None,
24
+ resultsTruncated: bool = False,
24
25
  cjaConnector: object = None,
25
26
  reportType: str = "normal",
26
27
  metrics: Union[dict, list] = None, ## for normal type, static report
@@ -34,6 +35,7 @@ class Workspace:
34
35
  dataRequest : REQUIRED : dataRequest containing the request
35
36
  columns : REQUIRED : the columns element of the response.
36
37
  summaryData : REQUIRED : summary data containing total calculated by CJA
38
+ resultsTruncated : OPTIONAL : whether or not the results returned were truncated
37
39
  cjaConnector : REQUIRED : cja connector.
38
40
  reportType : OPTIONAL : define type of report retrieved.(normal, static, multi)
39
41
  metrics : OPTIONAL : dictionary of the columns Id for normal report and list of columns name for Static report
@@ -50,6 +52,7 @@ class Workspace:
50
52
  self.settings = dataRequest["settings"]
51
53
  self.pageRequested = dataRequest["settings"]["page"] + 1
52
54
  self.summaryData = summaryData
55
+ self.resultsTruncated = resultsTruncated
53
56
  self.reportType = reportType
54
57
  self.cjaConnector = cjaConnector
55
58
  ## global filters resolution
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cjapy
3
- Version: 0.2.3.post2
3
+ Version: 0.2.3.post4
4
4
  Summary: Adobe Customer Journey Analytics (CJA) wrapper
5
5
  Home-page: https://github.com/pitchmuc/cjapy
6
6
  Author: Julien Piccini
@@ -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