Skip to main content

Python timeframe tool for time monitoring for each event, error handling, traceback recording...

Project description

timeframe

Python timeframe tool for time monitoring for each event, error handling, traceback recording...

Example

import random
with TimeFrame(name='Text request') as time_frame:
    with time_frame.create(name='Prompt') as group_prompt:
        with group_prompt.create(name='Prompt request', retries=5) as event_frame:
            function_call = False
            for frame in event_frame:
                with frame:
                    time.sleep(random.uniform(0, 0.4))  # Stimulate doing network operation
                    if random.random() < 0.7:
                        raise ValueError  # Stimulate a complete random chance of a network error occur
                    if random.random() < 0.9:
                        function_call = True
        if function_call:
            with group_prompt.create(name='Function call `mul`', retries=0):
                time.sleep(random.uniform(0, 0.01))  # Stimulate doing network operation
            with group_prompt.create(name='Function Response', retries=5) as event_frame:
                for frame in event_frame:
                    with frame:
                        time.sleep(random.uniform(0, 0.4))  # Stimulate doing network operation
                        if random.random() < 0.7:
                            raise ValueError  # Stimulate a complete random chance of a network error occur
>>> print(time_frame.traceback_format())
[596869.233s] Error raised on Attempt 'Attempt #1' from parent 'Prompt request' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 260, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError

[596869.397s] Error raised on Attempt 'Attempt #2' from parent 'Prompt request' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 260, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError

[596870.032s] Error raised on Attempt 'Attempt #1' from parent 'Function Response' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 271, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError

[596870.171s] Error raised on Attempt 'Attempt #2' from parent 'Function Response' at TimeFrame 'Text request':
Traceback (most recent call last):

  File "...\timeframe.py", line 271, in test
    raise ValueError  # Stimulate a complete random chance of a network error occur
    ^^^^^^^^^^^^^^^^

ValueError
>>> print(time_frame.frame_format_dc(limit=1024)) #Character limit of discord embed field value
Total: 0001.252s (Total Frames: 11)
✅-Prompt (0001.252s)
> ⚠️-Prompt request (0000.607s)
> - ❌-Attempt #1 (0000.203s)
> - ❌-Attempt #2 (0000.164s)
> - ✅-Attempt #3 (0000.240s)
> ✅-Function call `mul` (0000.005s)
> ⚠️-Function Response (0000.640s)
> - ❌-Attempt #1 (0000.390s)
> - ❌-Attempt #2 (0000.139s)
> - ✅-Attempt #3 (0000.111s)

Example: image

>>> print(time_frame.frame_format_mono()) # Use of export as file or display on console
Total: 0001.252s (Total Frames: 11)
✅-Text request (0001.252s)
  ✅-Prompt (0001.252s)
    ⚠️-Prompt request (0000.607s)
      ❌-Attempt #1 (0000.203s)
      ❌-Attempt #2 (0000.164s)
      ✅-Attempt #3 (0000.240s)
    ✅-Function call `mul` (0000.005s)
    ⚠️-Function Response (0000.640s)
      ❌-Attempt #1 (0000.390s)
      ❌-Attempt #2 (0000.139s)
      ✅-Attempt #3 (0000.111s)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timeframe_event-1.0.1.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timeframe_event-1.0.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file timeframe_event-1.0.1.tar.gz.

File metadata

  • Download URL: timeframe_event-1.0.1.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.4 Windows/10

File hashes

Hashes for timeframe_event-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c6330b2042db4aed474759b7d2bef76d5c5dfbf4bfa5853ca21f63b091e238c8
MD5 6f6276b73f9652a56be847224cb1ff86
BLAKE2b-256 39cd6a9937cc5ecad0fcfa7bdc6f10676f2a7fd4a671ce91c36e412a8408fed7

See more details on using hashes here.

File details

Details for the file timeframe_event-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: timeframe_event-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.4 Windows/10

File hashes

Hashes for timeframe_event-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce83520926c2005da06f7e12955e5a894e9a6b2e40ccb8ea128a599281614825
MD5 d30a9cbefe6913f9553e7cd1784331fc
BLAKE2b-256 b59ce35f6dd2afc9c5686ce8b34f0ac9d6e15f898c3e1ae5ca7a8c5b3e8771b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page