-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSDK-9607: add build and run options for all Python modules; remove run option for Go #4818
RSDK-9607: add build and run options for all Python modules; remove run option for Go #4818
Conversation
5d840b6
to
9b23811
Compare
9b23811
to
7f02db9
Compare
from viam.module.module import Module | ||
from .models.{{ .ModelSnake }} import {{ .ModelPascal }} | ||
sys.path.append(os.path.dirname(os.path.abspath(__file__))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? I don't like the idea of updating the path...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running build.sh
and run.sh
both fail in opposite ways. Using the relative path .models
fails when using the hot reloading method, but succeeds when just writing models
. run.sh
can't find models
, but can find .models
. If there's a better way for both methods to find models
, that would definitely be best. Python import errors are my nemesis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use a try/except
block when importing here, along with a comment explaining the details?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally lgtm though I share Naveed's preference for not updating path
.
from models.hello_sensor import HelloSensor | ||
except ModuleNotFoundError: | ||
# when running as local module with run.sh | ||
from .models.hello_sensor import HelloSensor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we still want ModelSnake
and ModelPascal
, rather than hard-coding HelloSensor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg 😅 That would have been embarrassing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with my new commit: please pay attention nicole
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Originally, users could only use the
run.sh
script for local Python modules, and only hot reloading for cloud Python modules. Both methods should be available for both, even if there's a default. Go should never be usingrun.sh
, as a user should not be building a Go binary on an embedded device every time a module is updated or restarted.Changes:
run.sh
from Golang modulesFlyby:
Testing Process:
do_command
to print a log.run.sh
.do_command()
from a sensor using local Python module -- ✅do_command()
from a sensor using cloud Python module -- ✅make setup
andmake build
do_command()
from a sensor using local Go module -- ✅do_command()
from a sensor using cloud Go module -- ✅do_command()
from a sensor using local Python module -- ✅do_command()
from a sensor using cloud Python module -- ✅