Skip to main content

This package does command line processing, allows for logging, and keeps track of start, end, and elapsed time, along with a bunch of other stuff.

Project description

How to use CMD Log time:

Write a Command file that teaches cmdlogtime how to parse your input args:

# first line is the description of what the program does.
# subsequent lines list positional arguments (PA), then key-value (KV)arguments (KVA).
# Positional line:
# PA_name|PA_Description|Is_out_dir|Is_Dir|Check_Directory|Is_file|Check_File|||
# Key/Value Line:
# KVA_name|KVA_Description|Is_out_dir|Is_Dir|Check_Directory|Is_file|Check_File|alternate_KVA_name|default value|type
# -print_x_thresh|print every X threshold|0|0|0|0|0|--print_every_x_threshold|1|int
# For KVAs for booleans, set default value to BOOLEANFALSE or BOOLEANTRUE.
# If default is BOOLEANFALSE, then if you set the flag it will be True. (or vice-versa)
# -get_top_words|get top most probable words|0|0|0|0|0|--get_top_probable_words|BOOLEANFALSE|
#  out_dir must be given.
# 
# Example below. First line describes the program
Compute AUCROC and other stats from infile. Print AUCROC and PR curves.
out_dir|Top level directory that holds all the results|1|1|1|0|0|||
infile|file path of file with a file with header in format call(1 or 0)\tX\tValue|0|0|0|1|1|||
-print_x_thresh|print every X threshold|0|0|0|0|0|--print_every_x_threshold|1|int

Call cmdlinetime from your code as follows:

#!/usr/bin/env python
#  need to import cmdlogtime
import cmdlogtime

#need to specify a command line definition file.  See example command line definition file in this directory.
COMMAND_LINE_DEF_FILE = "./processLincsCommandLine.txt"

#There is also an example python file that uses all this stuff in this directory.
def main():
    # Call cmdlogtime.begin() at the beginning of main()
    (start_time_secs, pretty_start_time, my_args, logfile) = cmdlogtime.begin(COMMAND_LINE_DEF_FILE, sys.argv[0])
    
    # the command line arguments will be in the my_args dictionary returned, so you can access them like this:
    get_treats_vectors = my_args["get_treats_vectors"]
    
    #  Then you put all of your code here.....
    
    # if you want to add stuff to the logfile:
    logfile.write("Run Skim here for each of the B terms files in B_TERMS_DIR")
       
    #The only functions you probably will ever need in cmdlogtime are begin(), end(), and maybe make_dir. Here's an example:
    cmdlogtime.make_dir(intermediate_out_dir)

    # Call cmdlogtime.end() at the end of main()
    cmdlogtime.end(logfile, start_time_secs)

if __name__ == "__main__":
    main()

Reference Blog: https://towardsdatascience.com/an-end-to-end-guide-to-publish-your-python-package-bdb56639662c

CHANGELOG

Version 0.0.1 10/24/2022

Version 0.0.2 10/24/2022

  • Whitespace Errors & Docstring

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

cmdlogtime-0.0.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

cmdlogtime-0.0.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file cmdlogtime-0.0.2.tar.gz.

File metadata

  • Download URL: cmdlogtime-0.0.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for cmdlogtime-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ec6f30c643396c0737197f4163b931ed6261b48b4319892737f3db5b42626a94
MD5 90aadf7ff0345f8a37fa160ea86e8b5a
BLAKE2b-256 56ef30228f175b0fcec51b59ca944606c618a94f785b9af0f737c01a0bea8504

See more details on using hashes here.

File details

Details for the file cmdlogtime-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: cmdlogtime-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for cmdlogtime-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 223e9cbda9308e401dcf44647ae0c603af4a736dd82aa32cd4581e2096ad1ecb
MD5 963e93503fce80bf7f9fd38513fa6a3b
BLAKE2b-256 1639d7fb72d0d6861bff3ba444ef71348415daa82fdf8eb35a4c6b7a1b0a3c77

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