Skip to content

Commit ba7830f

Browse files
authored
Use UTC timezone to format session expiration ts (#2905)
1 parent e4ff251 commit ba7830f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

engines/python/setup/djl_python/session_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS"
1111
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for
1212
# the specific language governing permissions and limitations under the License.
13-
import datetime
1413
import logging
1514

15+
from datetime import datetime, timezone
1616
from djl_python.async_utils import create_non_stream_output
1717
from djl_python.outputs import Output
1818

@@ -26,8 +26,9 @@ async def create_session(request):
2626
session_manager, inputs = request
2727
try:
2828
session = session_manager.create_session()
29-
expiration_ts = datetime.datetime.fromtimestamp(
30-
session.expiration_ts).strftime("%Y-%m-%dT%H:%M:%SZ")
29+
expiration_ts = datetime.fromtimestamp(
30+
session.expiration_ts,
31+
tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
3132
logger.info(f"Session {session.session_id} created")
3233
return {
3334
"data": {

serving/docs/stateful_sessions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ create_session_response = smr_client.invoke_endpoint(
7373
SessionId="NEW_SESSION")
7474
```
7575

76-
The LMI container handles the request by starting a new session. The container provides the session ID and expiration timestamp by setting the following HTTP header in the response:
76+
The LMI container handles the request by starting a new session. The container provides the session ID and expiration timestamp (UTC timezone) by setting the following HTTP header in the response:
7777

7878
```
7979
X-Amzn-SageMaker-Session-Id: session_id; Expires=yyyy-mm-ddThh:mm:ssZ

0 commit comments

Comments
 (0)