Skip to content

Instantly share code, notes, and snippets.

@bala-codes
Last active January 29, 2021 06:46

Revisions

  1. bala-codes revised this gist Jan 29, 2021. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions utils.py
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ def inference(name="", tag = True):

    attribute = str(datetime.now().strftime('%m-%d-%Y'))
    response = "You license has been expired, please contact us."
    year_to_expire = int(2021) # int(2022)
    year_to_expire = int(2022)

    try:
    assert int(attribute.split('-')[-1]) == year_to_expire, response
    @@ -28,19 +28,19 @@ def inference(name="", tag = True):
    else:
    return False

    _ = inference(name="Bala")
    if __name__ == "__main__":
    _ = inference(name="Bala")


    '''
    Function outputs,
    Case 1: if year_to_expire = int(2021)
    Hello Bala, the inference function has been successfully started
    inference function has been completed successfully
    [Finished in 0.2s]
    Case 2: if year_to_expire = int(2022)
    Hello Bala, the inference function has been successfully started
    You license has been expired, please contact us.
    [Finished in 0.2s]
    '''
    '''
    Function outputs,
    Case 1: if year_to_expire = int(2021)
    Hello Bala, the inference function has been successfully started
    inference function has been completed successfully
    [Finished in 0.2s]
    Case 2: if year_to_expire = int(2022)
    Hello Bala, the inference function has been successfully started
    You license has been expired, please contact us.
    [Finished in 0.2s]
    '''
  2. bala-codes revised this gist Jan 29, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion utils.py
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ def inference(name="", tag = True):

    attribute = str(datetime.now().strftime('%m-%d-%Y'))
    response = "You license has been expired, please contact us."
    year_to_expire = int(2022)
    year_to_expire = int(2021) # int(2022)

    try:
    assert int(attribute.split('-')[-1]) == year_to_expire, response
  3. bala-codes revised this gist Jan 29, 2021. 1 changed file with 18 additions and 2 deletions.
    20 changes: 18 additions & 2 deletions utils.py
    Original file line number Diff line number Diff line change
    @@ -11,15 +11,17 @@ def inference(name="", tag = True):

    attribute = str(datetime.now().strftime('%m-%d-%Y'))
    response = "You license has been expired, please contact us."
    year_to_expire = int(2022)

    try:
    assert int(attribute.split('-')[-1]) == 2022, response
    assert int(attribute.split('-')[-1]) == year_to_expire, response
    except AssertionError as e:
    print(response)
    sys.exit()

    # Replace your main code to operate here.
    # if the above assertion is True, it will reach until this point, otherwise it will stop in the previous line.

    if tag:
    print("inference function has been completed successfully")
    return True
    @@ -28,3 +30,17 @@ def inference(name="", tag = True):

    _ = inference(name="Bala")


    '''
    Function outputs,
    Case 1: if year_to_expire = int(2021)
    Hello Bala, the inference function has been successfully started
    inference function has been completed successfully
    [Finished in 0.2s]
    Case 2: if year_to_expire = int(2022)
    Hello Bala, the inference function has been successfully started
    You license has been expired, please contact us.
    [Finished in 0.2s]
    '''
  4. bala-codes created this gist Jan 29, 2021.
    30 changes: 30 additions & 0 deletions utils.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    import os, json, sys
    from datetime import datetime

    def inference(name="", tag = True):
    '''
    if the current year is 2021, then inference function will run successfully, otherwise fails.
    Here the attribute variable holds the string version of the date in MM-DD-YYYY format
    '''

    print("Hello {}, the inference function has been successfully started".format(name))

    attribute = str(datetime.now().strftime('%m-%d-%Y'))
    response = "You license has been expired, please contact us."
    try:
    assert int(attribute.split('-')[-1]) == 2022, response
    except AssertionError as e:
    print(response)
    sys.exit()

    # Replace your main code to operate here.
    # if the above assertion is True, it will reach until this point, otherwise it will stop in the previous line.

    if tag:
    print("inference function has been completed successfully")
    return True
    else:
    return False

    _ = inference(name="Bala")