Skip to content

Commit

Permalink
Fix #99: MODELDIR error in CLI (#100)
Browse files Browse the repository at this point in the history
Fix #99. Including improve CLI itself
  • Loading branch information
trentmc authored Aug 28, 2023
1 parent 209a73f commit c58d779
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
4 changes: 3 additions & 1 deletion pdr_backend/models/test/test_data_nft.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def test_set_ddo():
ddo = json.loads(content)

private_key = os.getenv("PRIVATE_KEY")
owner = Account.from_key(os.getenv("PRIVATE_KEY"))
owner = Account.from_key( # pylint:disable=no-value-for-parameter
private_key=private_key
)
rpc_url = os.getenv("RPC_URL")
web3_config = Web3Config(rpc_url, private_key)
factory = ERC721Factory(web3_config)
Expand Down
50 changes: 37 additions & 13 deletions pdr_backend/predictoor/main.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
import sys
from pdr_backend.predictoor.approach1.main import main as main1
from pdr_backend.predictoor.approach2.main import main as main2

HELP = """Predictoor runner.
Usage: python pdr_backend/predictoor/main.py APPROACH
where APPROACH=1 does random predictions
APPROACH=2 uses a model to predict. Needs MODELDIR specified.
"""


def _do_help():
print(HELP)
sys.exit()


def _do_main():
if len(sys.argv) <= 1:
_do_help()

arg1 = sys.argv[1]
if arg1 == "1":
from pdr_backend.predictoor.approach1.main import ( # pylint: disable=import-outside-toplevel,line-too-long
main,
)

main()

elif arg1 == "2":
from pdr_backend.predictoor.approach2.main import ( # pylint: disable=import-outside-toplevel,line-too-long
main,
)

main()

elif arg1 == "help":
_do_help()

def main():
if len(sys.argv) == 1:
main1()
else:
arg = sys.argv[1]
if arg == "1":
main1()
elif arg == "2":
main2()
else:
print("Invalid argument. Use '1' for approach1 or '2' for approach2.")
_do_help()


if __name__ == "__main__":
main()
_do_main()

0 comments on commit c58d779

Please sign in to comment.