-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added unittests for misc and get image * Add "post" method for RestApiV1 library * added init with get image and get countries * Added hashbang line to script * Added "post" to RestApiV1 * added more GET unit tests * Adding capability to get images _get_binary added to RestApiV1 * more unit tests under get_tests * Updated RestApiV1 "post" * change line endings to unix-style * Update .gitignore updated .gitignore to not include .swp, .pyc * more unit tests/edits * Change default REST API url * Converted RestApiV1 unit tests to use new functions instead of _get * Preparing for release 1.1 Release 1.1 allows using External ID and allows attaching subcomponents * Fixed bug with institution list --------- Co-authored-by: wagn0033 <[email protected]>
- Loading branch information
Showing
134 changed files
with
24,338 additions
and
879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
lib/Sisyphus/__pycache__/__init__.cpython-39.pyc | ||
*.pyc | ||
Examples/upload-docket/Tutorial/Example01/.~lock.HWItems.xlsx\# | ||
*.pyc | ||
*.pyc | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[codestyle] | ||
indentation = True | ||
edge_line = True | ||
edge_line_columns = 79 | ||
|
||
[main] | ||
version = 0.2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[encoding] | ||
text_encoding = utf-8 | ||
|
||
[main] | ||
version = 0.2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[vcs] | ||
use_version_control = False | ||
version_control_system = | ||
|
||
[main] | ||
version = 0.2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[workspace] | ||
restore_data_on_startup = True | ||
save_data_on_exit = True | ||
save_history = True | ||
save_non_project_files = False | ||
project_type = 'empty-project-type' | ||
recent_files = ['lib/Sisyphus/RestApiV1/__init__.py', 'test/RestApiV1/Test__get_misc.py'] | ||
|
||
[main] | ||
version = 0.2.0 | ||
recent_files = [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[codestyle] | ||
indentation = True | ||
edge_line = True | ||
edge_line_columns = 79 | ||
|
||
[main] | ||
version = 0.2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[codestyle] | ||
indentation = True | ||
edge_line = True | ||
edge_line_columns = 79 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[encoding] | ||
text_encoding = utf-8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[vcs] | ||
use_version_control = False | ||
version_control_system = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
restore_data_on_startup = True | ||
save_data_on_exit = True | ||
save_history = True | ||
save_non_project_files = False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[encoding] | ||
text_encoding = utf-8 | ||
|
||
[main] | ||
version = 0.2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[vcs] | ||
use_version_control = False | ||
version_control_system = | ||
|
||
[main] | ||
version = 0.2.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[workspace] | ||
restore_data_on_startup = True | ||
save_data_on_exit = True | ||
save_history = True | ||
save_non_project_files = False | ||
project_type = 'empty-project-type' | ||
recent_files = ['lib/Sisyphus/RestApiV1/__init__.py', 'test/RestApiV1/Test__get_misc.py', 'lib/Sisyphus/RestApi/__init__.py', 'scratch/scratch-01.py'] | ||
|
||
[main] | ||
version = 0.2.0 | ||
recent_files = [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
bin/advanced-upload-docket.py | ||
Copyright (c) 2023 Regents of the University of Minnesota | ||
Author: Alex Wagner <[email protected]>, Dept. of Physics and Astronomy | ||
""" | ||
|
||
import sys | ||
import argparse | ||
import json, json5 | ||
from Sisyphus.HWDBUploader import Docket | ||
|
||
def parse_args(argv): | ||
|
||
description = "TBD" | ||
|
||
arg_table = [ | ||
(('docket',), {"metavar": "filename", "nargs": 1}), | ||
#(('--docket',), {"dest": "docket", "required": True, "metavar": "filename"}), | ||
(('--submit',), {"dest": "submit", "action": "store_true"}), | ||
#(('--ignore-warnings',), {"dest": "ignore", "action": "store_true"}), | ||
] | ||
|
||
parser = argparse.ArgumentParser(description=description, add_help=True) | ||
|
||
for args, kwargs in arg_table: | ||
parser.add_argument(*args, **kwargs) | ||
|
||
# THIS IS BROKEN... I want to pass argv to it, but it just doesn't behave the same. | ||
# but I don't need to fix this right now. | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def main(argv): | ||
args = parse_args(argv) | ||
|
||
docket_file = args.docket[0] | ||
ext = docket_file.split('.')[-1] | ||
|
||
try: | ||
with open(docket_file, "r") as f: | ||
contents = f.read() | ||
except Exception as ex: | ||
print(f"Exception: {type(ex)} {ex}") | ||
raise ex | ||
|
||
if ext.lower() in ["json", "json5"]: | ||
docket_def = json5.loads(contents) | ||
elif ext.lower() in ["py",]: | ||
_locals = {} | ||
exec(contents, globals(), _locals) | ||
docket_def = _locals["contents"] | ||
|
||
docket = Docket(docket_def) | ||
|
||
docket.process_sources() | ||
if args.submit: | ||
docket.update_hwdb() | ||
else: | ||
docket.display_plan() | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" | ||
bin/list-institutions.py | ||
Copyright (c) 2023 Regents of the University of Minnesota | ||
Author: Alex Wagner <[email protected]>, Dept. of Physics and Astronomy | ||
""" | ||
|
||
from Sisyphus.Configuration import config | ||
logger = config.getLogger() | ||
|
||
from Sisyphus.RestApiV1 import get_institutions | ||
from Sisyphus.Utils.Terminal import Style | ||
import sys | ||
import json | ||
import argparse | ||
|
||
def parse(command_line_args=sys.argv): | ||
parser = argparse.ArgumentParser( | ||
add_help=True, | ||
parents=[config.arg_parser], | ||
description='Displays a list of available institution codes') | ||
parser.add_argument('--country', | ||
dest='country', | ||
metavar='<country code or name>', | ||
required=False, | ||
help='display only countries matching (or partially matching) string') | ||
parser.add_argument('--inst-name', '--institution-name', | ||
dest='name', | ||
metavar='<institution name>', | ||
required=False, | ||
help='display only institutions matching (or partially matching) string') | ||
parser.add_argument('--inst-id', | ||
dest='id', | ||
metavar='<institution id>', | ||
required=False, | ||
help='find the specific institution ID') | ||
args = parser.parse_known_args(command_line_args) | ||
return args | ||
|
||
def main(): | ||
logger.info("Listing institutions") | ||
|
||
args, unknowns = parse() | ||
|
||
resp = get_institutions() | ||
|
||
if resp['status'] != "OK": | ||
print("There was an error obtaining a list of institutions from the server") | ||
return 1 | ||
|
||
# Separate by country | ||
inst_by_country = {} | ||
countries = [] | ||
for inst in resp['data']: | ||
country_code = inst['country']['code'] | ||
country_name = inst['country']['name'] | ||
inst_id = inst['id'] | ||
inst_name = inst['name'] | ||
|
||
country_display_name = f"{country_name} ({country_code})" | ||
|
||
if args.country is not None: | ||
if args.country.upper() not in country_display_name.upper(): | ||
# skip this institution | ||
continue | ||
if args.name is not None: | ||
if args.name.upper() not in inst_name.upper(): | ||
# skip this institution | ||
continue | ||
if args.id is not None: | ||
if args.id != str(inst_id): | ||
# skip this institution | ||
continue | ||
|
||
if country_code not in inst_by_country.keys(): | ||
inst_by_country[country_code] = [] | ||
countries.append((country_code, country_display_name)) | ||
inst_by_country[country_code].append((inst_id, inst_name)) | ||
|
||
countries = [ (a, b) for (b, a) in | ||
sorted([(b, a) for (a, b) in countries]) ] | ||
|
||
if len(countries) == 0: | ||
print() | ||
print("No institutions found matching criteria") | ||
print() | ||
else: | ||
print() | ||
print("Institutions found:") | ||
print() | ||
for country_code, country_display_name in countries: | ||
|
||
institutions = [ (a, b) for (b, a) in | ||
sorted([(b, a) for (a, b) in inst_by_country[country_code]]) ] | ||
|
||
if args.country is None: | ||
print(country_display_name) | ||
else: | ||
print(Style.highlight(country_display_name, args.country)) | ||
|
||
print("="*len(country_display_name)) | ||
for inst_id, inst_name in institutions: | ||
if args.name is None: | ||
print(f"{inst_id:3d} {inst_name}") | ||
else: | ||
print(f"{inst_id:3d} {Style.highlight(inst_name, args.name)}") | ||
print() | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) | ||
|
Oops, something went wrong.