Skip to content

Fix package loading in Python runner#113

Merged
litvand merged 3 commits intodev/python-fixesfrom
al/py-pkg-init
Jan 6, 2022
Merged

Fix package loading in Python runner#113
litvand merged 3 commits intodev/python-fixesfrom
al/py-pkg-init

Conversation

@litvand
Copy link
Copy Markdown
Contributor

@litvand litvand commented Dec 20, 2021

🌟 What is the purpose of this PR?

Python init PR #2
Previous PR: #112

🔗 Related links

🔍 What does this change?

  • Ignores packages' owned fields temporarily
  • Fixes sending runner errors to Rust (using nng)
  • Fixes paths where packages are expected to be
  • Fixes hash_util import in packages

🛡 Tests

  • ✅ Manual Tests

❓ How to test this?

  1. Run any experiment.
  2. Check that Python reaches behavior execution or messages package init

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Dec 20, 2021

This pull request introduces 1 alert when merging bf51440 into 67a8cd8 - view on LGTM.com

new alerts:

  • 1 for Unused import

Copy link
Copy Markdown
Contributor

@Alfred-Mountfield Alfred-Mountfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking merging until #112 is merged and this branch is rebased for easier review

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 6, 2022

CLA assistant check
All committers have signed the CLA.

@litvand litvand changed the base branch from main to dev/python-fixes January 6, 2022 14:57
@github-actions github-actions bot added the area/content > hash.ai Affects the `hash.ai` informational site (content) label Jan 6, 2022
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jan 6, 2022

This pull request introduces 1 alert when merging 57f5f6118c37ee96e795ca23c0ddd5bb06c9c637 into f7bf804 - view on LGTM.com

new alerts:

  • 1 for Unused import

@github-actions github-actions bot removed the area/content > hash.ai Affects the `hash.ai` informational site (content) label Jan 6, 2022
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jan 6, 2022

This pull request introduces 1 alert when merging 3a8b19179da84e6b4352224467e15bda607b0d45 into b8274df - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jan 6, 2022

This pull request introduces 1 alert when merging b378392 into b8274df - view on LGTM.com

new alerts:

  • 1 for Unused import



# TODO(permanently?): Keep in sync with PACKAGE_TYPE
def str_from_pkg_type(t):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid single char variable names if possible?

def get_pkg_path(pkg_name, pkg_type):
return Path("../../../simulation/package/{}/packages/{}/package.py".format(
# The engine should be started from the engine's root directory in the repo.
return Path("./src/simulation/package/{}/packages/{}/package.py".format(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this works, it works. But it's something I'd like to revisit at some point, not happy about all of our relative paths and such, especially since things like running Python with -m can affect it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this does rely on running the engine from a specific directory.

# changing `sys.path` here (vs some more complicated way
# of importing files from parent directories of the
# package file's directory).
code = ("import pathlib\n" +
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed in a later PR so it's okay

# that the runner exited.

error = "Runner error: " + str(traceback.format_exception(type(exc), exc, tb))
error = "Runner error: " + str(traceback.format_exception(*exc_info))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we either pass the destructured args, or can we just type hint?

Or at least a comment saying it comes from the function so you can destructure

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jan 6, 2022

This pull request introduces 1 alert when merging bc657bf into b8274df - view on LGTM.com

new alerts:

  • 1 for Unused import

@litvand litvand merged commit 84bbc1b into dev/python-fixes Jan 6, 2022
@litvand litvand deleted the al/py-pkg-init branch January 6, 2022 19:52
@litvand litvand mentioned this pull request Jan 26, 2022
Alfred-Mountfield pushed a commit that referenced this pull request Mar 23, 2022
* Fix flatbuffers conversion during Python init (#112)

* Fix package loading in Python runner (#113)

* Fix line numbers in Python tracebacks (#114)

* Fix behavior execution package Python component init (#115)

* Fix messages package Python experiment init (#116)

* Fix Python runner init (#117)

* Fix Python execution (#214)

* Log received inbound messages in Python process

* Fix Python state snapshot sync

* Display flatc errors from genfbs.py

* Fix conflicting TaskMsg flatbuffers definitions

* Propagate JS inbound message receive errors

* Fix Python state interim sync

* Fix Python task execution

* Make Python error handling more consistent; update docstrings

* Enabling Python tests

* Adding Python setup to CI

* Building before setting up Python script in CI

* Only running Python setup from the root and building all

* Running python setup from the package root

* Changing python setup run cmd

* Specifying server in cargo build in workflow

* Running tests from the right cwd

* Debugging the contents of the github workspace

* Fix Python `context.step()`

* Changing output format on integration tests

* Fix a variety of Errors around the Python runner (#254)

* Fixed init tests

* Made behavior index private, and fixed incrementing with multi-language, and fixed access in Python

* Fixing behavior index field access in python to use full loading

* Fix receiving Python errors in Rust

* Removing outdated `server` reference from Rust workflow

* Fixing optional GroupIndex on TaskMsg

* Programmatically search for libhash_engine_lib.so

* Run state interim sync before `run_task` in Python

* Disable native python logging

* Fix outbound group index deserialization

* Fix Python integration tests implementation

* Properly check for metaversion in python

* Fix neighbor access in Python

* Disable behavior reusing

* Support index notation for Python

* Implement state sync for Python

Co-authored-by: litvand <8569704+litvand@users.noreply.github.com>
Co-authored-by: Alfred Mountfield <am@hash.ai>
Co-authored-by: Tim Diekmann <tim.diekmann@3dvision.de>
@vilkinsons vilkinsons added category/enhancement New feature or request and removed C-enhancement labels Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category/enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

4 participants