From 460c8ecfade92e7d895dea58682f84466b83d27f Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Mon, 4 Mar 2024 21:50:12 +0000 Subject: [PATCH 01/27] new pr database code --- ci/scripts/update_pr_database.py | 122 +++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100755 ci/scripts/update_pr_database.py diff --git a/ci/scripts/update_pr_database.py b/ci/scripts/update_pr_database.py new file mode 100755 index 0000000000..4538b85928 --- /dev/null +++ b/ci/scripts/update_pr_database.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 + +import os,sys + +from github import Github +from wxflow import Executable, which, SQLiteDB +from workflow.hosts import Host + +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE + +def full_path(string): + if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): + return os.path.abspath(string) + else: + raise NotADirectoryError(string) + +def create(db): + db.connect() + db.create_table('pr_list', ['pr INTEGER PRIMARY KEY', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) + db.disconnect() + +def add_pr(db, pr): + db.connect() + rows = db.fetch_data('pr_list') + for row in rows: + if str(row[0]) == str(args.add_pr[0]): + print(f"pr {row[0]} already is in list: nothing added") + sys.exit(0) + + entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') + db.insert_data('pr_list', entities) + db.disconnect() + + +def input_args(): + + description = """Arguments for creating and updating db file for pr states + """ + + parser = ArgumentParser(description=description, + formatter_class=ArgumentDefaultsHelpFormatter) + + parser.add_argument('--dbfile', help='SQLite3 database file with PR list', type=full_path) + parser.add_argument('--create', help='create sqlite file for pr list status', action='store_true', required=False) + parser.add_argument('--add_pr', nargs=1, metavar='PR', help='add new pr to list (defults to: Open,Ready)', required=False) + parser.add_argument('--remove_pr', nargs=1, metavar='PR', help='removes pr from list', required=False) + parser.add_argument('--update_pr', nargs=REMAINDER, metavar=('pr', 'state', 'status', 'reset_id', 'cases'), + help='updates state and status of a given pr', required=False) + parser.add_argument('--display', nargs='*', help='output pr table', required=False) + + args = parser.parse_args() + return args + +if __name__ == '__main__': + + args = input_args() + + if not args.create: + if not os.path.isfile(args.dbfile): + print(f'Error: {args.dbfile} does not exsist') + sys.exit(-1) + + ci_database = SQLiteDB(args.dbfile) + + match args: + case 'create': + create(ci_database) + case 'add_pr': + add_pr(ci_database, args.add_pr[0]) + + sys.exit(0) + + if args.update_pr: + if len(args.update_pr) < 2: + print(f"update_pr must have at least one vaule to update") + sys.exit(0) + pr = args.update_pr[0] + + ci_database.connect() + ci_database.update_data('pr_list', pr, args.update_pr[1:]) + ci_database.disconnect() + + if args.remove_pr: + ci_database.connect() + ci_database.remove_column('pr_list', args.remove_pr[0]) + ci_database.disconnect() + + if args.display is not None: + ci_database.connect() + rows = ci_database.fetch_data('pr_list') + if len(args.display) == 1: + for row in rows: + if int(args.display[0]) == int(row[0]): + print(' '.join(map(str, row))) + else: + for row in rows: + print(' '.join(map(str, row))) + ci_database.disconnect() + + sys.exit(0) + + gh_cli = which('gh') + gh_cli.add_default_arg(['auth', 'status','--show-token']) + gh_access_token=gh_cli(output=str, error=str).split('\n')[3].split(': ')[1] + gh = Github(gh_access_token) + + #repo = g.get_repo("TerrenceMcGuinness-NOAA/global-workflow") + repo = gh.get_repo("NOAA-EMC/global-workflow") + pulls = repo.get_pulls(state='open') + + host = Host() + pr_list = [] + for pull in pulls: + labels = pull.get_labels() + ci_labels = [s for s in labels if 'CI' in s.name] + for label in ci_labels: + if host.machine.capitalize() in label.name: + pr_list.append(pull) + print(f"With label: {label.name} the PR {pull.number} is added to list") + + + print(f"PR list: {pr_list}") \ No newline at end of file From b9dcab081d0fce460ef8767191676e7678224683 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Tue, 5 Mar 2024 00:08:47 +0000 Subject: [PATCH 02/27] made if else into match with functions --- ci/scripts/update_pr_database.py | 66 +++++++++++++++++--------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/ci/scripts/update_pr_database.py b/ci/scripts/update_pr_database.py index 4538b85928..2ec6342d10 100755 --- a/ci/scripts/update_pr_database.py +++ b/ci/scripts/update_pr_database.py @@ -31,6 +31,33 @@ def add_pr(db, pr): db.insert_data('pr_list', entities) db.disconnect() +def update_pr(db, pr): + if len(args.update_pr) < 2: + print(f"update_pr must have at least one vaule to update") + sys.exit(0) + pr = args.update_pr[0] + + db.connect() + db.update_data('pr_list', pr, args.update_pr[1:]) + db.disconnect() + +def remove_pr(db, pr): + db.connect() + db.remove_column('pr_list', args.remove_pr[0]) + db.disconnect() + +def display(db): + db.connect() + rows = db.fetch_data('pr_list') + if len(args.display) == 1: + for row in rows: + if int(args.display[0]) == int(row[0]): + print(' '.join(map(str, row))) + else: + for row in rows: + print(' '.join(map(str, row))) + db.disconnect() + def input_args(): @@ -62,40 +89,19 @@ def input_args(): ci_database = SQLiteDB(args.dbfile) - match args: + match args.option: case 'create': create(ci_database) case 'add_pr': add_pr(ci_database, args.add_pr[0]) - - sys.exit(0) - - if args.update_pr: - if len(args.update_pr) < 2: - print(f"update_pr must have at least one vaule to update") - sys.exit(0) - pr = args.update_pr[0] - - ci_database.connect() - ci_database.update_data('pr_list', pr, args.update_pr[1:]) - ci_database.disconnect() - - if args.remove_pr: - ci_database.connect() - ci_database.remove_column('pr_list', args.remove_pr[0]) - ci_database.disconnect() - - if args.display is not None: - ci_database.connect() - rows = ci_database.fetch_data('pr_list') - if len(args.display) == 1: - for row in rows: - if int(args.display[0]) == int(row[0]): - print(' '.join(map(str, row))) - else: - for row in rows: - print(' '.join(map(str, row))) - ci_database.disconnect() + case 'update_pr': + update_pr(ci_database, args.update_pr[0]) + case 'remove_pr': + remove_pr(ci_database, args.remove_pr[0]) + case 'display': + display(ci_database) + case _: + print("No valid option selected") sys.exit(0) From aff1d57ac74bbf46c02c9e2864f01fbf64cb5558 Mon Sep 17 00:00:00 2001 From: Terry McGuinness Date: Mon, 4 Mar 2024 19:08:40 -0600 Subject: [PATCH 03/27] made each input a functional call --- ci/scripts/update_pr_database.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/ci/scripts/update_pr_database.py b/ci/scripts/update_pr_database.py index 2ec6342d10..05e72b69dc 100755 --- a/ci/scripts/update_pr_database.py +++ b/ci/scripts/update_pr_database.py @@ -89,19 +89,16 @@ def input_args(): ci_database = SQLiteDB(args.dbfile) - match args.option: - case 'create': - create(ci_database) - case 'add_pr': - add_pr(ci_database, args.add_pr[0]) - case 'update_pr': - update_pr(ci_database, args.update_pr[0]) - case 'remove_pr': - remove_pr(ci_database, args.remove_pr[0]) - case 'display': - display(ci_database) - case _: - print("No valid option selected") + if args.create: + create(ci_database) + if args.add_pr: + add_pr(ci_database, args.add_pr[0]) + if args.update_pr: + update_pr(ci_database, args.update_pr[0]) + if remove_pr: + remove_pr(ci_database, args.remove_pr[0]) + if display: + display(ci_database) sys.exit(0) @@ -125,4 +122,4 @@ def input_args(): print(f"With label: {label.name} the PR {pull.number} is added to list") - print(f"PR list: {pr_list}") \ No newline at end of file + print(f"PR list: {pr_list}") From b9974e8915a0c156fa0e2dc9241760155ca06d73 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Tue, 5 Mar 2024 01:45:14 +0000 Subject: [PATCH 04/27] got mostly working --- ci/scripts/update_pr_database.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ci/scripts/update_pr_database.py b/ci/scripts/update_pr_database.py index 05e72b69dc..d8d744b46b 100755 --- a/ci/scripts/update_pr_database.py +++ b/ci/scripts/update_pr_database.py @@ -2,7 +2,7 @@ import os,sys -from github import Github +#from pygithub import Github from wxflow import Executable, which, SQLiteDB from workflow.hosts import Host @@ -46,18 +46,20 @@ def remove_pr(db, pr): db.remove_column('pr_list', args.remove_pr[0]) db.disconnect() -def display(db): +def display(db,args): + values = [] db.connect() rows = db.fetch_data('pr_list') if len(args.display) == 1: for row in rows: if int(args.display[0]) == int(row[0]): - print(' '.join(map(str, row))) - else: - for row in rows: - print(' '.join(map(str, row))) - db.disconnect() + values.append(' '.join(map(str, row))) + else: + for row in rows: + values.append(' '.join(map(str, row))) + db.disconnect() + return values def input_args(): @@ -90,15 +92,16 @@ def input_args(): ci_database = SQLiteDB(args.dbfile) if args.create: - create(ci_database) + create(ci_database) if args.add_pr: add_pr(ci_database, args.add_pr[0]) if args.update_pr: update_pr(ci_database, args.update_pr[0]) - if remove_pr: - remove_pr(ci_database, args.remove_pr[0]) - if display: - display(ci_database) + if args.remove_pr: + remove_pr(ci_database, args.remove_pr[0]) + if args.display is not None: + for rows in display(ci_database,args): + print(rows) sys.exit(0) From bf51d0de505702999d1c4305fbc9b3fbedec3eba Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Tue, 5 Mar 2024 22:15:20 +0000 Subject: [PATCH 05/27] rewrote pr_list_database.py using wxflow import SQLiteDB --- ci/scripts/get_labels.py | 28 ++++ ci/scripts/pr_list_database.py | 217 +++++++++++-------------------- ci/scripts/update_pr_database.py | 128 ------------------ ci/scripts/workflow | 1 + 4 files changed, 105 insertions(+), 269 deletions(-) create mode 100755 ci/scripts/get_labels.py delete mode 100755 ci/scripts/update_pr_database.py create mode 120000 ci/scripts/workflow diff --git a/ci/scripts/get_labels.py b/ci/scripts/get_labels.py new file mode 100755 index 0000000000..a47061a0e4 --- /dev/null +++ b/ci/scripts/get_labels.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +from github import Github +from wxflow import which +from workflow.hosts import Host + +if __name__ == "__main__": + + gh_cli = which('gh') + gh_cli.add_default_arg(['auth', 'status','--show-token']) + gh_access_token=gh_cli(output=str, error=str).split('\n')[3].split(': ')[1] + gh = Github(gh_access_token) + + #repo = g.get_repo("TerrenceMcGuinness-NOAA/global-workflow") + repo = gh.get_repo("NOAA-EMC/global-workflow") + pulls = repo.get_pulls(state='open') + + host = Host() + pr_list = [] + for pull in pulls: + labels = pull.get_labels() + ci_labels = [s for s in labels if 'CI' in s.name] + for label in ci_labels: + if host.machine.capitalize() in label.name: + pr_list.append(pull) + print(f"label: {label.name} PR: {pull.number}") + + print(f"pr_list: {pr_list}") \ No newline at end of file diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 224aabd361..95bdcf4da8 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -1,155 +1,114 @@ #!/usr/bin/env python3 -import sys -import os -from pathlib import Path +import sys, os +from wxflow import SQLiteDB from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE -import sqlite3 - def full_path(string): - """ - Gets the absolute path of the given file and confirms the directory exists - - Parameters - ---------- - string : str - Path to a file - - Returns - -------- - str - Absolute path of input path - - Raises - ------- - NotADirectoryError - If the target directory for the file does not exist. - - """ - if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) else: raise NotADirectoryError(string) - - -def sql_connection(filename: os.path) -> sqlite3.Connection: + +def create(db): """ - Returns an Sqlite3 Cursor object from a given path to a sqlite3 database file + Create a new database. Parameters ---------- - filename : Path - Full path to a sqlite3 database file - - Returns - ------- - sqlite3.Connection - Sqlite3 Connection object for updating table - + ci_database : SQLiteDB + The database to create. """ - try: - return sqlite3.connect(filename) - except sqlite3.Error: - print(sqlite3.Error) - sys.exit(-1) - + db.create_table('pr_list', ['pr INTEGER PRIMARY KEY', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) -def sql_table(obj: sqlite3.Cursor) -> None: +def add_pr(db, pr): """ - Creates the initial sqlite3 table for PR states and status + Add a pull request to the database. Parameters ---------- - obj : sqlite3.Cursor - Cursor object for Sqlite3 - - """ - - obj.execute("CREATE TABLE processing(pr integer PRIMARY KEY, state text, status text, reset_id integer, cases text)") - - -def sql_insert(obj: sqlite3.Cursor, entities: list) -> None: + ci_database : SQLiteDB + The database to add the pull request to. + pr : str + The pull request to add. """ - Inserts a new row in sqlite3 table with PR, state, and status + rows = db.fetch_data('pr_list') + for row in rows: + if str(row[0]) == str(args.add_pr[0]): + print(f"pr {row[0]} already is in list: nothing added") + sys.exit(0) - Parameters - ---------- - obj : sqlite3.Cursor - Cursor object for Sqlite3 - entities : list - A list of four string values that go into sqlite table (pr, state, status, reset_id, cases) - pr: pull request number - state: The new value for the state (Open, Closed) - status: The new value for the status (Ready, Running, Failed) - reset_id: The value for number of times reset_id to Ready - cases: String containing case selection information + entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') + db.insert_data('pr_list', entities) +def update_pr(db, args): """ - - obj.execute('INSERT INTO processing(pr, state, status, reset_id, cases) VALUES(?, ?, ?, ?, ?)', entities) - - -def sql_update(obj: sqlite3.Cursor, pr: str, updates: dict) -> None: - """Updates table for a given pr with new values for state and status + Update a pull request in the database. Parameters ---------- - obj : sqlite.sql_connection - sqlite3 Cursor Object - pr : str - The given pr number to update in the table - updates : dict - Dictionary of values to update for a given PR to include by postion - state, The new value for the state (Open, Closed) - status, The new value for the status (Ready, Running, Failed) - reset_id, The value for number of times reset_id to Ready - cases, Information regarding which cases are used (i.e. self PR) - - """ + ci_database : SQLiteDB + The database to update the pull request in. + args : argparse.Namespace + The command line arguments. + """ + if len(args.update_pr) < 2: + print(f"update_pr must have at least one vaule to update") + sys.exit(0) update_list = ['state', 'status', 'reset_id', 'cases'] - rows = sql_fetch(obj) - for value in updates: + for value in args.update_pr[1:]: update = update_list.pop(0) - obj.execute(f'UPDATE processing SET "{update}" = "{value}" WHERE pr = {pr}') - + db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) -def sql_fetch(obj: sqlite3.Cursor) -> list: - """ Gets list of all rows in table +def remove_pr(db, args): + """ + Remove a pull request from the database. Parameters ---------- - obj : sqlite.sql_connection - sqlite3 Cursor Object + ci_database : SQLiteDB + The database to remove the pull request from. + pr : str + The pull request to remove. + """ + db.remove_column('pr_list', args.remove_pr[0]) +def display(db, args): """ - - obj.execute('SELECT * FROM processing') - return obj.fetchall() - - -def sql_remove(obj: sqlite3.Cursor, pr: str) -> None: - """ Removes the row from table with given pr number + Display the database. Parameters ---------- - obj : sqlite.sql_connection - sqlite3 Connection Object - pr : str - pr number acting as key for removing the row with in it + ci_database : SQLiteDB + The database to display. + args : argparse.Namespace + The command line arguments. + Returns + ------- + list + The rows of the database. """ + values = [] + if len(args.display) == 1: + rows = db.fetch_data('pr_list',['pr','state','status','reset_id','cases'],f'pr = {args.display[0]}') + else: + rows = db.fetch_data('pr_list',['pr','state','status','reset_id','cases']) + for row in rows: + values.append(' '.join(map(str, row))) - obj.execute(f'DELETE FROM processing WHERE pr = {pr}').rowcount - + return values def input_args(): - - description = """Arguments for creating and updating db file for pr states """ + Parse command line arguments. + Returns + ------- + argparse.Namespace + The parsed command line arguments. + """ parser = ArgumentParser(description=description, formatter_class=ArgumentDefaultsHelpFormatter) @@ -164,7 +123,6 @@ def input_args(): args = parser.parse_args() return args - if __name__ == '__main__': args = input_args() @@ -174,42 +132,19 @@ def input_args(): print(f'Error: {args.dbfile} does not exsist') sys.exit(-1) - con = sql_connection(args.dbfile) - obj = con.cursor() + ci_database = SQLiteDB(args.dbfile) + ci_database.connect() if args.create: - sql_table(obj) - + create(ci_database) if args.add_pr: - rows = sql_fetch(obj) - for row in rows: - if str(row[0]) == str(args.add_pr[0]): - print(f"pr {row[0]} already is in list: nothing added") - sys.exit(0) - - entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') - sql_insert(obj, entities) - + add_pr(ci_database, args.add_pr[0]) if args.update_pr: - if len(args.update_pr) < 2: - print(f"update_pr must have at least one vaule to update") - sys.exit(0) - pr = args.update_pr[0] - - sql_update(obj, pr, args.update_pr[1:]) - + update_pr(ci_database, args) if args.remove_pr: - sql_remove(obj, args.remove_pr[0]) - + remove_pr(ci_database, args.remove_pr[0]) if args.display is not None: - rows = sql_fetch(obj) - if len(args.display) == 1: - for row in rows: - if int(args.display[0]) == int(row[0]): - print(' '.join(map(str, row))) - else: - for row in rows: - print(' '.join(map(str, row))) - - con.commit() - con.close() + for rows in display(ci_database,args): + print(rows) + + ci_database.disconnect() diff --git a/ci/scripts/update_pr_database.py b/ci/scripts/update_pr_database.py deleted file mode 100755 index d8d744b46b..0000000000 --- a/ci/scripts/update_pr_database.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python3 - -import os,sys - -#from pygithub import Github -from wxflow import Executable, which, SQLiteDB -from workflow.hosts import Host - -from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE - -def full_path(string): - if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): - return os.path.abspath(string) - else: - raise NotADirectoryError(string) - -def create(db): - db.connect() - db.create_table('pr_list', ['pr INTEGER PRIMARY KEY', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) - db.disconnect() - -def add_pr(db, pr): - db.connect() - rows = db.fetch_data('pr_list') - for row in rows: - if str(row[0]) == str(args.add_pr[0]): - print(f"pr {row[0]} already is in list: nothing added") - sys.exit(0) - - entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') - db.insert_data('pr_list', entities) - db.disconnect() - -def update_pr(db, pr): - if len(args.update_pr) < 2: - print(f"update_pr must have at least one vaule to update") - sys.exit(0) - pr = args.update_pr[0] - - db.connect() - db.update_data('pr_list', pr, args.update_pr[1:]) - db.disconnect() - -def remove_pr(db, pr): - db.connect() - db.remove_column('pr_list', args.remove_pr[0]) - db.disconnect() - -def display(db,args): - values = [] - db.connect() - rows = db.fetch_data('pr_list') - if len(args.display) == 1: - for row in rows: - if int(args.display[0]) == int(row[0]): - values.append(' '.join(map(str, row))) - else: - for row in rows: - values.append(' '.join(map(str, row))) - - db.disconnect() - return values - -def input_args(): - - description = """Arguments for creating and updating db file for pr states - """ - - parser = ArgumentParser(description=description, - formatter_class=ArgumentDefaultsHelpFormatter) - - parser.add_argument('--dbfile', help='SQLite3 database file with PR list', type=full_path) - parser.add_argument('--create', help='create sqlite file for pr list status', action='store_true', required=False) - parser.add_argument('--add_pr', nargs=1, metavar='PR', help='add new pr to list (defults to: Open,Ready)', required=False) - parser.add_argument('--remove_pr', nargs=1, metavar='PR', help='removes pr from list', required=False) - parser.add_argument('--update_pr', nargs=REMAINDER, metavar=('pr', 'state', 'status', 'reset_id', 'cases'), - help='updates state and status of a given pr', required=False) - parser.add_argument('--display', nargs='*', help='output pr table', required=False) - - args = parser.parse_args() - return args - -if __name__ == '__main__': - - args = input_args() - - if not args.create: - if not os.path.isfile(args.dbfile): - print(f'Error: {args.dbfile} does not exsist') - sys.exit(-1) - - ci_database = SQLiteDB(args.dbfile) - - if args.create: - create(ci_database) - if args.add_pr: - add_pr(ci_database, args.add_pr[0]) - if args.update_pr: - update_pr(ci_database, args.update_pr[0]) - if args.remove_pr: - remove_pr(ci_database, args.remove_pr[0]) - if args.display is not None: - for rows in display(ci_database,args): - print(rows) - - sys.exit(0) - - gh_cli = which('gh') - gh_cli.add_default_arg(['auth', 'status','--show-token']) - gh_access_token=gh_cli(output=str, error=str).split('\n')[3].split(': ')[1] - gh = Github(gh_access_token) - - #repo = g.get_repo("TerrenceMcGuinness-NOAA/global-workflow") - repo = gh.get_repo("NOAA-EMC/global-workflow") - pulls = repo.get_pulls(state='open') - - host = Host() - pr_list = [] - for pull in pulls: - labels = pull.get_labels() - ci_labels = [s for s in labels if 'CI' in s.name] - for label in ci_labels: - if host.machine.capitalize() in label.name: - pr_list.append(pull) - print(f"With label: {label.name} the PR {pull.number} is added to list") - - - print(f"PR list: {pr_list}") diff --git a/ci/scripts/workflow b/ci/scripts/workflow new file mode 120000 index 0000000000..cb1a6b006d --- /dev/null +++ b/ci/scripts/workflow @@ -0,0 +1 @@ +../../workflow/ \ No newline at end of file From 837479708b1d161906ecb9df5828e5c85994624d Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Tue, 5 Mar 2024 22:26:37 +0000 Subject: [PATCH 06/27] removed pygithub work --- ci/scripts/get_labels.py | 28 ---------------------------- ci/scripts/workflow | 1 - 2 files changed, 29 deletions(-) delete mode 100755 ci/scripts/get_labels.py delete mode 120000 ci/scripts/workflow diff --git a/ci/scripts/get_labels.py b/ci/scripts/get_labels.py deleted file mode 100755 index a47061a0e4..0000000000 --- a/ci/scripts/get_labels.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 - -from github import Github -from wxflow import which -from workflow.hosts import Host - -if __name__ == "__main__": - - gh_cli = which('gh') - gh_cli.add_default_arg(['auth', 'status','--show-token']) - gh_access_token=gh_cli(output=str, error=str).split('\n')[3].split(': ')[1] - gh = Github(gh_access_token) - - #repo = g.get_repo("TerrenceMcGuinness-NOAA/global-workflow") - repo = gh.get_repo("NOAA-EMC/global-workflow") - pulls = repo.get_pulls(state='open') - - host = Host() - pr_list = [] - for pull in pulls: - labels = pull.get_labels() - ci_labels = [s for s in labels if 'CI' in s.name] - for label in ci_labels: - if host.machine.capitalize() in label.name: - pr_list.append(pull) - print(f"label: {label.name} PR: {pull.number}") - - print(f"pr_list: {pr_list}") \ No newline at end of file diff --git a/ci/scripts/workflow b/ci/scripts/workflow deleted file mode 120000 index cb1a6b006d..0000000000 --- a/ci/scripts/workflow +++ /dev/null @@ -1 +0,0 @@ -../../workflow/ \ No newline at end of file From 4f8583254cebf78129d035ad79169674e6e41b91 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Tue, 5 Mar 2024 22:42:30 +0000 Subject: [PATCH 07/27] added pylint spaces --- ci/scripts/pr_list_database.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 95bdcf4da8..c03fbbbb08 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -import sys, os +import sys +import os from wxflow import SQLiteDB from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE @@ -92,9 +93,9 @@ def display(db, args): """ values = [] if len(args.display) == 1: - rows = db.fetch_data('pr_list',['pr','state','status','reset_id','cases'],f'pr = {args.display[0]}') + rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f'pr = {args.display[0]}') else: - rows = db.fetch_data('pr_list',['pr','state','status','reset_id','cases']) + rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases']) for row in rows: values.append(' '.join(map(str, row))) From 45c80fb74deaeae767df9879e9270ce98bd0fdc9 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Tue, 5 Mar 2024 22:50:31 +0000 Subject: [PATCH 08/27] more pycodestyle spaces --- ci/scripts/pr_list_database.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index c03fbbbb08..dc71f0ff9b 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -5,12 +5,14 @@ from wxflow import SQLiteDB from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE + def full_path(string): if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) else: raise NotADirectoryError(string) - + + def create(db): """ Create a new database. @@ -22,6 +24,7 @@ def create(db): """ db.create_table('pr_list', ['pr INTEGER PRIMARY KEY', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) + def add_pr(db, pr): """ Add a pull request to the database. @@ -42,6 +45,7 @@ def add_pr(db, pr): entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') db.insert_data('pr_list', entities) + def update_pr(db, args): """ Update a pull request in the database. @@ -52,7 +56,7 @@ def update_pr(db, args): The database to update the pull request in. args : argparse.Namespace The command line arguments. - """ + """ if len(args.update_pr) < 2: print(f"update_pr must have at least one vaule to update") sys.exit(0) @@ -62,6 +66,7 @@ def update_pr(db, args): update = update_list.pop(0) db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) + def remove_pr(db, args): """ Remove a pull request from the database. @@ -72,9 +77,10 @@ def remove_pr(db, args): The database to remove the pull request from. pr : str The pull request to remove. - """ + """ db.remove_column('pr_list', args.remove_pr[0]) + def display(db, args): """ Display the database. @@ -101,6 +107,7 @@ def display(db, args): return values + def input_args(): """ Parse command line arguments. @@ -124,6 +131,7 @@ def input_args(): args = parser.parse_args() return args + if __name__ == '__main__': args = input_args() @@ -145,7 +153,7 @@ def input_args(): if args.remove_pr: remove_pr(ci_database, args.remove_pr[0]) if args.display is not None: - for rows in display(ci_database,args): + for rows in display(ci_database, args): print(rows) ci_database.disconnect() From d2866a67294919b411fb82426d62a2b7495d5b9c Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Thu, 7 Mar 2024 09:41:48 -0500 Subject: [PATCH 09/27] Update ci/scripts/pr_list_database.py Co-authored-by: Rahul Mahajan --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index dc71f0ff9b..efcada2284 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -19,7 +19,7 @@ def create(db): Parameters ---------- - ci_database : SQLiteDB + db : SQLiteDB The database to create. """ db.create_table('pr_list', ['pr INTEGER PRIMARY KEY', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) From 64f74411b1574e60cc63c2dd8b02fe9de0a82426 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 15:27:26 +0000 Subject: [PATCH 10/27] replaced search for uniquness in adding pr to state database with UNIQUE constraint within the table --- ci/scripts/pr_list_database.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index dc71f0ff9b..236c455b88 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -22,7 +22,7 @@ def create(db): ci_database : SQLiteDB The database to create. """ - db.create_table('pr_list', ['pr INTEGER PRIMARY KEY', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) + db.create_table('pr_list', ['pr INTEGER PRIMARY KEY UNIQUE', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) def add_pr(db, pr): @@ -37,13 +37,12 @@ def add_pr(db, pr): The pull request to add. """ rows = db.fetch_data('pr_list') - for row in rows: - if str(row[0]) == str(args.add_pr[0]): - print(f"pr {row[0]} already is in list: nothing added") - sys.exit(0) - entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') - db.insert_data('pr_list', entities) + try: + db.insert_data('pr_list', entities) + except (SQLiteDB.IntegrityError) as e: + if str(e) == "PRIMARY KEY must be unique": + print(f"pr {entities[0]} already is in list: nothing added") def update_pr(db, args): @@ -117,6 +116,9 @@ def input_args(): argparse.Namespace The parsed command line arguments. """ + + description = """Arguments for creating and updating db file for pr states + """ parser = ArgumentParser(description=description, formatter_class=ArgumentDefaultsHelpFormatter) From 37cad0a6386cc29a6406b579393c55b92e966ba3 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 17:38:30 +0000 Subject: [PATCH 11/27] added error exception class for SQLiteDB --- ci/scripts/pr_list_database.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 2e5fdbed71..4a53cfc445 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -5,7 +5,6 @@ from wxflow import SQLiteDB from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE - def full_path(string): if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) @@ -40,7 +39,7 @@ def add_pr(db, pr): entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') try: db.insert_data('pr_list', entities) - except (SQLiteDB.IntegrityError) as e: + except (SQLiteDB.Error.IntegrityError) as e: if str(e) == "PRIMARY KEY must be unique": print(f"pr {entities[0]} already is in list: nothing added") From e11df59e8dd402122aad3ae8f040db19adfd4ed5 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 18:32:45 +0000 Subject: [PATCH 12/27] updated hash for wxflow to include SQLite class and its latest updates --- sorc/wxflow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorc/wxflow b/sorc/wxflow index dd9ca24a5b..a35ad18ef8 160000 --- a/sorc/wxflow +++ b/sorc/wxflow @@ -1 +1 @@ -Subproject commit dd9ca24a5bb14b75acde685e5fa23b300fd47770 +Subproject commit a35ad18ef8cad45e76e0032177d00da2a13db564 From 086297048ee545bb62139f48696baad77205b41c Mon Sep 17 00:00:00 2001 From: Terry McGuinness Date: Fri, 8 Mar 2024 13:05:28 -0600 Subject: [PATCH 13/27] added better condtion on checkout error code string for when user tries to add pr already in the ci state database --- ci/scripts/pr_list_database.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 4a53cfc445..7566142f22 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -35,12 +35,11 @@ def add_pr(db, pr): pr : str The pull request to add. """ - rows = db.fetch_data('pr_list') entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') try: db.insert_data('pr_list', entities) except (SQLiteDB.Error.IntegrityError) as e: - if str(e) == "PRIMARY KEY must be unique": + if 'UNIQUE constraint failed' in str(e): print(f"pr {entities[0]} already is in list: nothing added") From c2e64738bb6212f827d21ea0b3378a2bf922f160 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 19:17:23 +0000 Subject: [PATCH 14/27] simplyfied test for uniqueness to account for different versions of squlite3 --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 7566142f22..e60f070c7d 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -39,7 +39,7 @@ def add_pr(db, pr): try: db.insert_data('pr_list', entities) except (SQLiteDB.Error.IntegrityError) as e: - if 'UNIQUE constraint failed' in str(e): + if 'unique' in str(e).lower(): print(f"pr {entities[0]} already is in list: nothing added") From fe3a0071807c24a3f1e286fa637c00310388fbe6 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 19:35:40 +0000 Subject: [PATCH 15/27] improved args to function calls and their types --- ci/scripts/pr_list_database.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index e60f070c7d..f9b14c6217 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -12,7 +12,7 @@ def full_path(string): raise NotADirectoryError(string) -def create(db): +def create(db: SQLiteDB): """ Create a new database. @@ -24,7 +24,7 @@ def create(db): db.create_table('pr_list', ['pr INTEGER PRIMARY KEY UNIQUE', 'state TEXT', 'status TEXT', 'reset_id INTEGER', 'cases TEXT']) -def add_pr(db, pr): +def add_pr(db: SQLiteDB, pr: str): """ Add a pull request to the database. @@ -35,15 +35,15 @@ def add_pr(db, pr): pr : str The pull request to add. """ - entities = (args.add_pr[0], 'Open', 'Ready', 0, 'ci_repo') + entities = (pr, 'Open', 'Ready', 0, 'ci_repo') try: db.insert_data('pr_list', entities) except (SQLiteDB.Error.IntegrityError) as e: if 'unique' in str(e).lower(): - print(f"pr {entities[0]} already is in list: nothing added") + print(f"pr {pr} already is in list: nothing added") -def update_pr(db, args): +def update_pr(db: SQLiteDB, args): """ Update a pull request in the database. @@ -64,7 +64,7 @@ def update_pr(db, args): db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) -def remove_pr(db, args): +def remove_pr(db: SQLiteDB, pr: str): """ Remove a pull request from the database. @@ -75,10 +75,10 @@ def remove_pr(db, args): pr : str The pull request to remove. """ - db.remove_column('pr_list', args.remove_pr[0]) + db.remove_data('pr_list','PR', pr) -def display(db, args): +def display(db, display): """ Display the database. @@ -95,8 +95,8 @@ def display(db, args): The rows of the database. """ values = [] - if len(args.display) == 1: - rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f'pr = {args.display[0]}') + if len(display) == 1: + rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases'], f'pr = {display[0]}') else: rows = db.fetch_data('pr_list', ['pr', 'state', 'status', 'reset_id', 'cases']) for row in rows: @@ -153,7 +153,7 @@ def input_args(): if args.remove_pr: remove_pr(ci_database, args.remove_pr[0]) if args.display is not None: - for rows in display(ci_database, args): + for rows in display(ci_database, args.display): print(rows) ci_database.disconnect() From c15d45750e99a3ed952d496796091d30bc8f8b7e Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 21:43:06 +0000 Subject: [PATCH 16/27] remove orion from gefs case for testing non system build bash ci --- ci/cases/pr/C48_S2SWA_gefs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/cases/pr/C48_S2SWA_gefs.yaml b/ci/cases/pr/C48_S2SWA_gefs.yaml index d42f4cd15b..759f995a73 100644 --- a/ci/cases/pr/C48_S2SWA_gefs.yaml +++ b/ci/cases/pr/C48_S2SWA_gefs.yaml @@ -16,3 +16,6 @@ arguments: idate: 2021032312 edate: 2021032312 yaml: {{ HOMEgfs }}/ci/cases/yamls/gefs_ci_defaults.yaml + +skip_ci_on_hosts: + - orion From ac49e30a1201d752728608f499acf2ca1714524e Mon Sep 17 00:00:00 2001 From: Terry McGuinness Date: Fri, 8 Mar 2024 15:59:25 -0600 Subject: [PATCH 17/27] took orion skip back out of gefs case --- ci/cases/pr/C48_S2SWA_gefs.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/ci/cases/pr/C48_S2SWA_gefs.yaml b/ci/cases/pr/C48_S2SWA_gefs.yaml index 759f995a73..d42f4cd15b 100644 --- a/ci/cases/pr/C48_S2SWA_gefs.yaml +++ b/ci/cases/pr/C48_S2SWA_gefs.yaml @@ -16,6 +16,3 @@ arguments: idate: 2021032312 edate: 2021032312 yaml: {{ HOMEgfs }}/ci/cases/yamls/gefs_ci_defaults.yaml - -skip_ci_on_hosts: - - orion From cdc69ffb82b493494ea0f0f04634b6aef3f542ca Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 22:29:10 +0000 Subject: [PATCH 18/27] updated SQLiteDB.Error to SQLiteDBError --- ci/scripts/pr_list_database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index f9b14c6217..957e8e231f 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -2,7 +2,7 @@ import sys import os -from wxflow import SQLiteDB +from wxflow import SQLiteDB, SQLiteDBError from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE def full_path(string): @@ -38,7 +38,7 @@ def add_pr(db: SQLiteDB, pr: str): entities = (pr, 'Open', 'Ready', 0, 'ci_repo') try: db.insert_data('pr_list', entities) - except (SQLiteDB.Error.IntegrityError) as e: + except (SQLiteDBError.IntegrityError) as e: if 'unique' in str(e).lower(): print(f"pr {pr} already is in list: nothing added") From 56df6de8ad5ed1807a0dd1ea851f0741ab164ab0 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Fri, 8 Mar 2024 23:39:41 +0000 Subject: [PATCH 19/27] added gitmodule dir for wxflow with some last minute changes to SQLiteDB Class for exposint exctiptions --- sorc/wxflow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorc/wxflow b/sorc/wxflow index a35ad18ef8..942b90bfaa 160000 --- a/sorc/wxflow +++ b/sorc/wxflow @@ -1 +1 @@ -Subproject commit a35ad18ef8cad45e76e0032177d00da2a13db564 +Subproject commit 942b90bfaa14f6b6d7374310dbdfd421ddb30548 From 966e288f339e46c07b078e20205e8364f3bee620 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Sun, 10 Mar 2024 20:14:37 +0000 Subject: [PATCH 20/27] remove function was redundent so was removed --- ci/scripts/pr_list_database.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 957e8e231f..bd111b8fcd 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -3,7 +3,7 @@ import sys import os from wxflow import SQLiteDB, SQLiteDBError -from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER, ZERO_OR_MORE +from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER def full_path(string): if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): @@ -64,20 +64,6 @@ def update_pr(db: SQLiteDB, args): db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) -def remove_pr(db: SQLiteDB, pr: str): - """ - Remove a pull request from the database. - - Parameters - ---------- - ci_database : SQLiteDB - The database to remove the pull request from. - pr : str - The pull request to remove. - """ - db.remove_data('pr_list','PR', pr) - - def display(db, display): """ Display the database. @@ -127,7 +113,6 @@ def input_args(): parser.add_argument('--update_pr', nargs=REMAINDER, metavar=('pr', 'state', 'status', 'reset_id', 'cases'), help='updates state and status of a given pr', required=False) parser.add_argument('--display', nargs='*', help='output pr table', required=False) - args = parser.parse_args() return args @@ -151,7 +136,7 @@ def input_args(): if args.update_pr: update_pr(ci_database, args) if args.remove_pr: - remove_pr(ci_database, args.remove_pr[0]) + ci_database.remove_data('pr_list','PR',args.remove_pr[0]) if args.display is not None: for rows in display(ci_database, args.display): print(rows) From 32c3ce211bba2bd766dc63f7fefb50247433266d Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Sun, 10 Mar 2024 20:07:31 -0400 Subject: [PATCH 21/27] Update pr_list_database.py spaces --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index bd111b8fcd..541b362bb3 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -136,7 +136,7 @@ def input_args(): if args.update_pr: update_pr(ci_database, args) if args.remove_pr: - ci_database.remove_data('pr_list','PR',args.remove_pr[0]) + ci_database.remove_data('pr_list', 'PR', args.remove_pr[0]) if args.display is not None: for rows in display(ci_database, args.display): print(rows) From e3fdde524dad9498e54e7c74c0ba609ced5831b5 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Mon, 11 Mar 2024 18:31:53 +0000 Subject: [PATCH 22/27] pynorms space added --- ci/scripts/pr_list_database.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 541b362bb3..f6253c528d 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -5,6 +5,7 @@ from wxflow import SQLiteDB, SQLiteDBError from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter, REMAINDER + def full_path(string): if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) From b12fcb203b2bd8aaa097ad17fbced777eb4ce51d Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Mon, 11 Mar 2024 17:04:06 -0400 Subject: [PATCH 23/27] Update ci/scripts/pr_list_database.py Co-authored-by: Walter Kolczynski - NOAA --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index f6253c528d..9c45d8164e 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -13,7 +13,7 @@ def full_path(string): raise NotADirectoryError(string) -def create(db: SQLiteDB): +def create_table(db: SQLiteDB): """ Create a new database. From a95bd1f04f7e5ad9935e4079c5444cc83e5bd76b Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Mon, 11 Mar 2024 17:04:47 -0400 Subject: [PATCH 24/27] Update ci/scripts/pr_list_database.py Co-authored-by: Walter Kolczynski - NOAA --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 9c45d8164e..95bb8d034c 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -15,7 +15,7 @@ def full_path(string): def create_table(db: SQLiteDB): """ - Create a new database. + Create a new table in a database. Parameters ---------- From c6b0a16b8cada497765cd2bf2163799d1b08e0c8 Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Mon, 11 Mar 2024 21:13:53 +0000 Subject: [PATCH 25/27] updated few names and added docsting for fullpath --- ci/scripts/pr_list_database.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 95bb8d034c..323b4462de 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -7,6 +7,24 @@ def full_path(string): + """ + full_path Get the absolute path of a file or directory. + + Parameters + ---------- + string : str + The relative path of the file or directory. + + Returns + ------- + str + The absolute path of the file or directory. + + Raises + ------ + NotADirectoryError + If the provided string does not represent a valid file or directory. + """ if os.path.isfile(string) or os.path.isdir(os.path.dirname(string)): return os.path.abspath(string) else: @@ -65,7 +83,7 @@ def update_pr(db: SQLiteDB, args): db.update_data('pr_list', update, value, 'pr', args.update_pr[0]) -def display(db, display): +def display_db(db, display): """ Display the database. @@ -73,8 +91,8 @@ def display(db, display): ---------- ci_database : SQLiteDB The database to display. - args : argparse.Namespace - The command line arguments. + display : list + The command line argument values. Returns ------- @@ -131,7 +149,7 @@ def input_args(): ci_database.connect() if args.create: - create(ci_database) + create_table(ci_database) if args.add_pr: add_pr(ci_database, args.add_pr[0]) if args.update_pr: @@ -139,7 +157,7 @@ def input_args(): if args.remove_pr: ci_database.remove_data('pr_list', 'PR', args.remove_pr[0]) if args.display is not None: - for rows in display(ci_database, args.display): + for rows in display_db(ci_database, args.display): print(rows) ci_database.disconnect() From cb33781174716fb64071b789863bf336880659ca Mon Sep 17 00:00:00 2001 From: tmcguinness Date: Mon, 11 Mar 2024 21:16:59 +0000 Subject: [PATCH 26/27] removed whitespace per pycodestyle --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index 323b4462de..c4ba4bcabb 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -91,7 +91,7 @@ def display_db(db, display): ---------- ci_database : SQLiteDB The database to display. - display : list + display : list The command line argument values. Returns From d44e68e9aee937c0fd00eaac92f2ef3755a325d4 Mon Sep 17 00:00:00 2001 From: TerrenceMcGuinness-NOAA Date: Mon, 11 Mar 2024 17:45:33 -0400 Subject: [PATCH 27/27] Update ci/scripts/pr_list_database.py Co-authored-by: Walter Kolczynski - NOAA --- ci/scripts/pr_list_database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/scripts/pr_list_database.py b/ci/scripts/pr_list_database.py index c4ba4bcabb..f525d64987 100755 --- a/ci/scripts/pr_list_database.py +++ b/ci/scripts/pr_list_database.py @@ -68,7 +68,7 @@ def update_pr(db: SQLiteDB, args): Parameters ---------- - ci_database : SQLiteDB + db : SQLiteDB The database to update the pull request in. args : argparse.Namespace The command line arguments.