aws-samples / sagemaker-run-notebook

Tools to run Jupyter notebooks as jobs in Amazon SageMaker - ad hoc, on a schedule, or in response to events
Apache License 2.0
142 stars 69 forks source link

Unable to list rules #25

Closed sagar1025 closed 3 years ago

sagar1025 commented 3 years ago

I'm using the JupyterLab extension.

In a new terminal, sh-4.2$ run-notebook list-rules Name Notebook Parameters Schedule Event Pattern Traceback (most recent call last): File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/bin/run-notebook", line 8, in sys.exit(main()) File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/sagemaker_run_notebook/cli.py", line 543, in main args.func(args) File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/sagemaker_run_notebook/cli.py", line 247, in list_rules params = params = [f"{k}={v}" for k, v in r["parameters"].items()] AttributeError: 'str' object has no attribute 'items'

I was trying to view the schedules I have set. I could not find a command option to view a list of schedules for a notebook similar to list-rules so I used list-rules instead. Is this an actual issue or is there another command to view the schedules for a notebook?

tomfaulhaber commented 3 years ago

@sagar1025 Yes, schedules are a kind of rule, so run-notebook list-rules should show them.

My guess here is that you got a broken rule (an event bridge rule without a target, in event bridge lingo). That can happen because (a) the was an IAM permission issue when creating the rule (did you get an error?), (b) you deleted the target or otherwise modified rules directly using AWS tools and they ended up in a bad state, or (c) ... who knows.

I was handling that case wrong in the code (defaulting to a string value instead of a dict) and that's now fixed so it shouldn't crash anymore. I'll push a new release that incorporates the fix soon.

Thanks for reporting this!

sagar1025 commented 3 years ago

Thanks for fixing this! This was a couple of months ago but I believe that the most likely cause was an IAM role issue.