Automic Workload Automation

  • 1.  Convert between task run ID & job report ID

    Posted Jun 27, 2016 02:11 PM
    Edited by Michael A. Lowry Mar 01, 2024 05:15 AM

    Recently I did some investigation into the relationship between task run IDs and job report IDs. I discovered the following:

    • A task run ID is represented in the Automation Engine by a 31 bit integer (between 1 and 2147483647).
    • A job report ID is the base-26 representation of a task run ID. The letter A represents the numeral 0;B, 1; and so on up to Z, which represents the numeral 25. The job report ID is padded with leading zeros (As) to bring the total number of digits to 7. Represented in this way, a job report ID can be any base-26 number between AAAAAAB and GYTISYX.
    • Neither RUNNR2ALPHA nor ALPHA2RUNNRperforms range checking. Both return a meaningless result if provided input values exceeding 31 bits. (Because task IDs beyond 31 bits cannot exist, 2147483647 is the highest decimal run ID, and GYTISYX the highest alphabetic job report ID, for which these commands will return a meaningful result.)
    • Gytis is a masculine Lithuanian given name.

    I wrote a couple of scripts to convert between task run ID and job report ID. This makes it possible to do these conversions without relying on AE scripting. I also added some basic range checking.

    runnr2alpha.py

    import sys
    numargs = len(sys.argv)
    if len(sys.argv) < 2:
    sys.exit("Too few arguments")
    elif len(sys.argv) > 2:
    sys.exit("Too many arguments")
    
    runid = int(sys.argv[1])
    if runid > 2147483647:
    sys.exit("Run ID exceeds maximum 2147483647 (2^31 - 1).")
    elif runid < 0:
    sys.exit("Run ID may not be negative.")
    
    def int_to_str(n, b, symbols='ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
    return (int_to_str(n/b, b, symbols) if n >= b else "") + symbols[n%b]
    
    def int_to_lstr(n):
    i = int_to_str(int(n), 26)
    while(len(i) < 7):
    i = 'A' + i
    return i
    
    jobid = int_to_lstr(runid)
    print jobid

    alpha2runnr.py

    import sys
    numargs = len(sys.argv)
    if len(sys.argv) < 2:
    sys.exit("Too few arguments")
    elif len(sys.argv) > 2:
    sys.exit("Too many arguments")
    
    jobid = sys.argv[1]
    if len(jobid) != 7:
    sys.exit("Job ID must be exactly 7 characters.")
    
    alpha = set('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
    if not set(jobid).issubset(alpha):
    sys.exit("Job ID may contain only alphabetic characters.")
    
    jobid = jobid.upper()
    
    def str_to_int(s, b, symbols='ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
    r = s[::-1]
    d = 0
    j = 0
    for c in r:
    d = (symbols.index(c) * pow(b,j)) + d
    j += 1
    return d
    
    def str_to_int_add(s):
    i = str_to_int(s, 26)
    if i > 2147483647:
    sys.exit("GYTISYX is the highest possible alphabetic job report ID.")
    return i
    
    runid = str_to_int_add(jobid)
    print runid

     

    Enjoy!

    Thanks to N. C. for her help with the original script.



  • 2.  Convert between task run ID & job report ID

    Posted Jul 01, 2016 09:51 AM
    Hi Michael!

    This is just awesome. How did you find this out?

    Thanks for sharing your work.

    //Carsten


  • 3.  Convert between task run ID & job report ID

    Posted Jul 01, 2016 09:55 AM
    This is just awesome. How did you find this out?
    Trial and error, mostly. See this comment.


  • 4.  RE: Convert between task run ID & job report ID

    Posted Mar 30, 2021 10:40 AM
    Edited by Carsten Schmitz Mar 30, 2021 12:25 PM
    Sadly, this forum is not suited for Python code :(


    File "runnr2alpha.py", line 4
    sys.exit("Too few arguments")
    ^
    IndentationError: expected an indented block


    Edit: this website may work as well. Still easier than making an Automic script:
    https://www.dcode.fr/base-26-cipher


  • 5.  RE: Convert between task run ID & job report ID

    Posted Mar 31, 2021 09:05 AM
    Edited by Michael A. Lowry Mar 31, 2021 09:05 AM
    Just another reminder that Higher Logic is not ready for prime time.



  • 6.  RE: Convert between task run ID & job report ID

    Posted Nov 21, 2022 05:46 AM
    Edited by Michael A. Lowry Mar 01, 2024 03:16 AM

    @Jason McClellan: Any chance you could repair the python code blocks corrupted by the Jive-to-HL migration?​​



  • 7.  RE: Convert between task run ID & job report ID

    Posted Mar 01, 2024 03:18 AM

    @Jason McClellan: Never mind. I fixed the code blocks by simply opening them them and then directly closing them again.




  • 8.  RE: Convert between task run ID & job report ID

    Broadcom Employee
    Posted Mar 01, 2024 04:22 AM

    Hi all!

    There are also the script functions ALPHA2RUNNR and RUNNR2ALPHA.

    See docu-pages:

    Michael



    ------------------------------
    Michael K. Dolinek

    Engineering Program Manager | Agile Operation Division
    Broadcom Software
    ------------------------------



  • 9.  RE: Convert between task run ID & job report ID

    Posted Mar 01, 2024 04:49 AM

    Yep! I mentioned them in the original post. 😊