Skip to content

Commit

Permalink
Merge pull request #1 from jameshalgren/pytestini1
Browse files Browse the repository at this point in the history
Add the pytest ini
  • Loading branch information
RohanSunkarapalli authored Oct 31, 2023
2 parents bfa52bd + 75d84cb commit 8c2866f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
55 changes: 37 additions & 18 deletions nwmurl/urlgennwm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#from gevent import monkey
#monkey.patch_all()
from dateutil import rrule
from datetime import datetime, timezone, timedelta
from itertools import product
Expand Down Expand Up @@ -32,6 +30,7 @@
vardict = {1: "channel_rt", 2: "land", 3: "reservoir", 4: "terrain_rt", 5: "forcing"}
geodict = {1: "conus", 2: "hawaii", 3: "puertorico"}


def selectvar(vardict, varinput):
return vardict[varinput]

Expand Down Expand Up @@ -174,7 +173,7 @@ def selecturlbase(urlbasedict, urlbaseinput, defaulturlbase=""):
else:
return defaulturlbase


def generate_urls_retro(
start_date=None,
end_date=None,
Expand Down Expand Up @@ -209,9 +208,9 @@ def generate_urls_retro(
file_list.extend(file_names)
else:
file_list.append(file_names)
if write_to_file == True:
if write_to_file == True:
if os.path.exists("retro_filenamelist.txt"):
os.remove("retro_filenamelist.txt")
os.remove("retro_filenamelist.txt")
with open("retro_filenamelist.txt", "wt") as file:
for item in file_list:
file.write(f"{item}\n")
Expand Down Expand Up @@ -475,28 +474,48 @@ def generate_url_retro(date, file_type, urlbase_prefix, retrospective_var_types=
]

return url


def generate_urls_operational(start_date,end_date, fcst_cycle, lead_time, varinput, geoinput, runinput, urlbaseinput, meminput, write_to_file=False):


def generate_urls_operational(
start_date,
end_date,
fcst_cycle,
lead_time,
varinput,
geoinput,
runinput,
urlbaseinput,
meminput,
write_to_file=False,
):
start_date = start_date
end_date = end_date
end_date = end_date
fcst_cycle = fcst_cycle
# fcst_cycle = None # Retrieves a full day for each day within the range given.
#lead_time = [1]
# lead_time = [1]
lead_time = lead_time
varinput = varinput
#vardict = {1: "channel_rt", 2: "land", 3: "reservoir", 4: "terrain_rt", 5: "forcing"}
# vardict = {1: "channel_rt", 2: "land", 3: "reservoir", 4: "terrain_rt", 5: "forcing"}
geoinput = geoinput
#geodict = {1: "conus", 2: "hawaii", 3: "puertorico"}
# geodict = {1: "conus", 2: "hawaii", 3: "puertorico"}
meminput = meminput
urlbaseinput = urlbaseinput
runinput = runinput

if runinput == 1 or runinput == 5 or runinput == 6 or runinput == 7 or runinput == 8 or runinput == 9 or runinput == 10 or runinput == 11:
meminput = None
print("no ensemble members available for the given runinput therefore, meminput set to None")

if (
runinput == 1
or runinput == 5
or runinput == 6
or runinput == 7
or runinput == 8
or runinput == 9
or runinput == 10
or runinput == 11
):
meminput = None
print(
"no ensemble members available for the given runinput therefore, meminput set to None"
)
# rundict = {
# 1: "short_range",
# 2: "medium_range",
Expand All @@ -522,7 +541,7 @@ def generate_urls_operational(start_date,end_date, fcst_cycle, lead_time, varinp
urlbaseinput,
lead_time,
)
if (write_to_file==True):
if write_to_file == True:
if os.path.exists("filenamelist.txt"):
os.remove("filenamelist.txt")
if urlbaseinput == 9:
Expand All @@ -533,4 +552,4 @@ def generate_urls_operational(start_date,end_date, fcst_cycle, lead_time, varinp
with open("filenamelist.txt", "wt") as file:
for item in file_list:
file.write(f"{item}\n")
return file_list
return file_list
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath = nwmurl
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"""

# Other information
VERSION = '0.1.5'
DESCRIPTION = 'URL generator tool for National Water Model data'
VERSION = "0.1.5"
DESCRIPTION = "URL generator tool for National Water Model data"

setup(
name="nwmurl",
Expand All @@ -45,13 +45,13 @@
long_description=LONG_DESCRIPTION,
long_description_content_type="text/x-rst",
packages=find_packages(),
keywords=['python', 'NWM', 'url'],
keywords=["python", "NWM", "url"],
classifiers=[
"Development Status :: 1 - Planning",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
]
],
)
File renamed without changes.

0 comments on commit 8c2866f

Please sign in to comment.