Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPlayer3 committed Dec 13, 2024
1 parent 54129ed commit 2be43c9
Show file tree
Hide file tree
Showing 31 changed files with 1,347 additions and 1,722 deletions.
10 changes: 5 additions & 5 deletions src/hyp3_isce2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# ISCE2 sets the root logger to DEBUG resulting in excessively verbose logging, see:
# https://github.com/isce-framework/isce2/issues/258
root_logger = logging.getLogger()
root_logger.setLevel("WARNING")
root_logger.setLevel('WARNING')

# ISCE2 also needs its applications to be on the system path, even though they say it's only "for convenience", see:
# https://github.com/isce-framework/isce2#setup-your-environment
ISCE_APPLICATIONS = str(Path(os.environ["ISCE_HOME"]) / "applications")
if ISCE_APPLICATIONS not in (PATH := os.environ["PATH"].split(os.pathsep)):
os.environ["PATH"] = os.pathsep.join([ISCE_APPLICATIONS] + PATH)
ISCE_APPLICATIONS = str(Path(os.environ['ISCE_HOME']) / 'applications')
if ISCE_APPLICATIONS not in (PATH := os.environ['PATH'].split(os.pathsep)):
os.environ['PATH'] = os.pathsep.join([ISCE_APPLICATIONS] + PATH)

__version__ = version(__name__)

__all__ = [
"__version__",
'__version__',
]
40 changes: 18 additions & 22 deletions src/hyp3_isce2/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,48 @@ def main():
Calls the HyP3 entrypoint specified by the `++process` argument
"""
parser = argparse.ArgumentParser(
prefix_chars="+", formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser = argparse.ArgumentParser(prefix_chars='+', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
"++process",
'++process',
choices=[
"insar_tops_burst",
"insar_tops",
"insar_stripmap",
"merge_tops_bursts",
'insar_tops_burst',
'insar_tops',
'insar_stripmap',
'merge_tops_bursts',
],
default="insar_tops_burst",
help="Select the HyP3 entrypoint to use", # HyP3 entrypoints are specified in `pyproject.toml`
default='insar_tops_burst',
help='Select the HyP3 entrypoint to use', # HyP3 entrypoints are specified in `pyproject.toml`
)
parser.add_argument(
"++omp-num-threads",
'++omp-num-threads',
type=int,
help="The number of OpenMP threads to use for parallel regions",
help='The number of OpenMP threads to use for parallel regions',
)

args, unknowns = parser.parse_known_args()

username = os.getenv("EARTHDATA_USERNAME")
password = os.getenv("EARTHDATA_PASSWORD")
username = os.getenv('EARTHDATA_USERNAME')
password = os.getenv('EARTHDATA_PASSWORD')
if username and password:
write_credentials_to_netrc_file(username, password, append=False)

if not (Path.home() / ".netrc").exists():
if not (Path.home() / '.netrc').exists():
warnings.warn(
"Earthdata credentials must be present as environment variables, or in your netrc.",
'Earthdata credentials must be present as environment variables, or in your netrc.',
UserWarning,
)

# NOTE: Cast to set because of: https://github.com/pypa/setuptools/issues/3649
# NOTE: Will need to update to `entry_points(group='hyp3', name=args.process)` when updating to python 3.10
eps = entry_points()["hyp3"]
(process_entry_point,) = {
process for process in eps if process.name == args.process
}
eps = entry_points()['hyp3']
(process_entry_point,) = {process for process in eps if process.name == args.process}

if args.omp_num_threads:
os.environ["OMP_NUM_THREADS"] = str(args.omp_num_threads)
os.environ['OMP_NUM_THREADS'] = str(args.omp_num_threads)

sys.argv = [args.process, *unknowns]
sys.exit(process_entry_point.load()())


if __name__ == "__main__":
if __name__ == '__main__':
main()
Loading

0 comments on commit 2be43c9

Please sign in to comment.