Skip to content

Commit 4073b27

Browse files
authored
Release version: 2.7.2 (#45)
2 parents 504b7e9 + 836a14a commit 4073b27

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

ads/ads_version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "2.7.1"
2+
"version": "2.7.2"
33
}

ads/common/oci_logging.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class OCILog(OCILoggingModelMixin, oci.logging.models.Log):
205205
"""Represents the OCI Log resource.
206206
207207
Usage: (OCI requires display_name to be unique and it cannot contain space)
208-
>>> log = OCILog.create(display_name="My_Log", log_group_id=LOG_GROUP_ID)
208+
>>> log = OCILog(display_name="My_Log", log_group_id=LOG_GROUP_ID).create()
209209
Usually it is better to create a log using the create_log() method in OCILogGroup.
210210
>>> log.delete() # Delete the resource
211211
Get a log object from OCID
@@ -269,15 +269,17 @@ def create_async(self):
269269
self.log_group_id, self.to_oci_model(oci.logging.models.CreateLogDetails)
270270
)
271271

272-
def sync(self) -> None:
272+
def sync(self, **kwargs) -> None:
273273
"""Refreshes the properties of the Log model
274274
OCI requires both Log OCID and Log group OCID to get the Log model.
275275
276276
This method override the sync() method from OCIMixin to improve performance.
277277
"""
278278
if not self.log_group_id:
279279
self.log_group_id = self._get_log_group_id(self.id, self.compartment_id)
280-
self.update_from_oci_model(self.client.get_log(self.log_group_id, self.id).data)
280+
self.update_from_oci_model(
281+
self.client.get_log(self.log_group_id, self.id).data, **kwargs
282+
)
281283
return self
282284

283285
def delete(self):
@@ -522,6 +524,7 @@ def _search_and_format(
522524
limit: int = LOG_RECORDS_LIMIT,
523525
sort_by: str = "datetime",
524526
sort_order: str = SortOrder.DESC,
527+
log_filter: str = None,
525528
):
526529
"""Returns the formatted log records.
527530
@@ -539,6 +542,9 @@ def _search_and_format(
539542
The field for sorting the logs.
540543
sort_order: (str, optional). Defaults to "DESC".
541544
The sort order for the log records. Can be "ASC" or "DESC".
545+
log_filter : (str, optional). Defaults to None.
546+
Expression for filtering the logs.
547+
This will be the WHERE clause of the query.
542548
543549
Returns
544550
-------
@@ -556,6 +562,7 @@ def _search_and_format(
556562
limit=limit,
557563
sort_by=sort_by,
558564
sort_order=sort_order,
565+
log_filter=log_filter,
559566
)
560567
logs = sorted((log.data for log in logs), key=lambda x: x.get("datetime"))
561568
logs = [log.get("logContent", {}) for log in logs]
@@ -573,6 +580,7 @@ def tail(
573580
source: str = None,
574581
limit=LOG_RECORDS_LIMIT,
575582
time_start: datetime.datetime = None,
583+
log_filter: str = None,
576584
) -> List[dict]:
577585
"""Returns the most recent log records.
578586
@@ -586,6 +594,9 @@ def tail(
586594
time_start: (datetime.datetime, optional)
587595
Starting time for the log query.
588596
Defaults to None. Logs up to 14 days from now will be returned.
597+
log_filter : (str, optional). Defaults to None.
598+
Expression for filtering the logs.
599+
This will be the WHERE clause of the query.
589600
590601
Returns
591602
-------
@@ -594,7 +605,11 @@ def tail(
594605
Each log record is a dictionary with the following keys: `id`, `time`, `message`.
595606
"""
596607
return self._search_and_format(
597-
source=source, limit=limit, sort_order=SortOrder.DESC, time_start=time_start
608+
source=source,
609+
limit=limit,
610+
sort_order=SortOrder.DESC,
611+
time_start=time_start,
612+
log_filter=log_filter,
598613
)
599614

600615
def head(
@@ -632,6 +647,7 @@ def stream(
632647
interval: int = LOG_INTERVAL,
633648
stop_condition: callable = None,
634649
time_start: datetime.datetime = None,
650+
log_filter: str = None,
635651
):
636652
"""Streams logs to console/terminal until stop_condition() returns true.
637653
@@ -646,6 +662,10 @@ def stream(
646662
time_start: datetime.datetime
647663
Starting time for the log query.
648664
Defaults to None. Logs up to 14 days from now will be returned.
665+
log_filter : str, optional
666+
Expression for filtering the logs.
667+
This will be the WHERE clause of the query.
668+
Defaults to None.
649669
650670
Returns
651671
-------
@@ -664,7 +684,9 @@ def stream(
664684
next_time_start = datetime.datetime.utcnow() - datetime.timedelta(
665685
seconds=180
666686
)
667-
logs = self.tail(source, limit=None, time_start=time_start)
687+
logs = self.tail(
688+
source, limit=None, time_start=time_start, log_filter=log_filter
689+
)
668690
# Update time_start if the tail() is successful
669691
time_start = next_time_start
670692
except Exception:

docs/source/release_notes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Release Notes
33
=============
44

5+
2.7.2
6+
-----
7+
Release date: December 20, 2022
8+
9+
* Fixed a bug in ADS jobs. The ``job_run.watch()`` sometimes stuck infinitely and threw an exception.
10+
11+
512
2.7.1
613
-----
714
Release date: December 14, 2022

0 commit comments

Comments
 (0)