Skip to main content

Display elapsed time on Jupyter.

Project description

jupyter-autotime

Display elapsed time on Jupyter.

Demo

Getting start

  1. Install

    • On shell.

      pip install jupyter-autotime
      
    • On Jupyter.

      !pip install jupyter-autotime
      
  2. Enable autotime

    %load_ext autotime
    

Other usage

# Reload.
%reload_ext autotime

# Disable.
%unload_ext autotime

Customization

  • First, import the module to hack autotime.

    import autotime
    
  • Customize timespan format.

    def my_format_timepan(timespan: float) -> str):
       """My custom timespan format."""
       # e.g. '12 sec'
       return '{} sec'.format(int(timespan))
    autotime.format_timespan = my_format_timepan
    
  • Customize time format.

    # e.g. '2020/12/10 16:15:11'
    autotime.TIME_FORMAT = '%Y/%m/%d %H:%M:%S'
    
  • Customize output format.

    # e.g. '[RUNNING] 3.09 s (2020-12-10T15:58:35)'
    autotime.RUNNING_FORMAT = '[RUNNING] {timespan} ({start})'
    # e.g. '[FINISH] 4.02 s (2020-12-10T15:59:54~2020-12-10T15:59:58)'
    autotime.FINISHED_FORMAT = '[FINISH] {timespan} ({start}~{end})'
    
  • Customize units.

    # e.g. 5 分 7 秒
    autotime.set_units(sec='秒', min='分', hr='時間', d='日')
    
  • Customize output with method.

    def my_format_output(timespan: float,
                         start_time: time.struct_time,
                         end_time: float = None,
                         is_finished: bool = False):
       """My Custom output format."""
       if is_finished:
          # e.g. 'Finished. 2.0160000000032596'
          return 'Finished. {}'.format(timespan)
       else:
          # e.g. 'Running... 1.0159999999887077'
          return 'Running... {}'.format(timespan)
    
    
    autotime.format_output = my_format_output
    
    • You can access below objects on custom format_output.
      • autotime.UNITS (dict)
      • autotime.format_time (method)
      • autotime.TIME_FORMAT (str)
      • autotime.RUNNING_FORMAT (str)
      • autotime.FINISHED_FORMAT (str)

Development

  • Requirements: poetry, pyenv
poetry install

poetry publish

pip install --no-cache-dir --upgrade jupyter-autotime

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

jupyter-autotime-1.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

jupyter_autotime-1.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file jupyter-autotime-1.1.0.tar.gz.

File metadata

  • Download URL: jupyter-autotime-1.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.6.8 Windows/10

File hashes

Hashes for jupyter-autotime-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7cfdccf0419fe6b9a374f8a4ae03f1479e6f8f9145a56da0e3fc083ec9c1f21d
MD5 16d5112c113ee8ee525ebb48f17c2a41
BLAKE2b-256 444d62dbd00f1080d357a032f9f39b6a689090a33db739e306cff39f47fbc3d7

See more details on using hashes here.

File details

Details for the file jupyter_autotime-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyter_autotime-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b657f83af43f7f5fb11eefeaf9675c0d1a756c87260f2972f3ea2103bf42a6cd
MD5 76c47a8f3974d0b6105e220cc6ccd2b1
BLAKE2b-256 00d4e092493a2326c9c780315f6e3f9e9cfb238386565d3ff919e59567ff93c2

See more details on using hashes here.

Supported by

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