Skip to content
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

CON-1192: Python API integrated with simulation mode #87

Merged
merged 17 commits into from
Nov 7, 2022

Conversation

shamsasari
Copy link
Contributor

@shamsasari shamsasari commented Nov 3, 2022

The user can now create a Python enclave by creating an enclave Gradle module with a single Python script in src/main/python (everything else in the Gradle project stays the same). The plugin will detect this and will take a fat jar of the python-enclave-adapter module, the Python script, the generated Gramine manifest (which is now created dynamically based on the local environment), and will bundle them into a zip file. This zip file is what the host will scan for when it loads an enclave. Any future data that needs to be part of a Gramine enclave can be put into this zip bundle as well.

The enclave scanning process was been rewritten to support this zip Gramine “bundle”, alongwith the existing .so GraalVM “bundle”. The Gramine enclave process will pick up this optional Python file and manually set it on the PythonEnclaveAdapter object.

The runtimeType enclave config has been made less strict and will now ignore case. For Python enclaves it will default to Gramine, rejecting any GraalVM config.

A new python enclave has been added to the integration tests and which does a very basic Python test. This should be updated to something more substantial such as PyTorch. The integration tests had to be cleaned up to ensure it was running, including fixing the docker container so that Gramine can run inside it. This now means the Gramine integration tests no longer hang, but for some reason the Python test does not execute, even though it passes when run directly.

The user can now create a Python enclave by creating an enclave Gradle module with a single Python script in `src/main/python` (everything else in the Gradle project stays the same). The plugin will detect this and will take a fat jar of the `python-enclave-adapter` module, the Python script, the generated Gramine manifest (which is now created dynamically based on the local environment), and will bundle them into a zip file. This zip file is what the host will scan for when it loads an enclave. Any future data that needs to be part of a Gramine enclave can be put into this zip bundle.

The enclave scanning process was been rewritten to support this zip Gramine “bundle”, alongwith the existing .so GraalVM “bundle”. The Gramine enclave process will pick up this optional Python file and manually set it on the `PythonEnclaveAdapter` object.

Note, the integration test currently hangs on TC though it passes if run separately. It is only testing a very basic Python enclave, but instead should be updated to use something like PyTorch.
@shamsasari
Copy link
Contributor Author

There's already a new release of Jep, https://github.com/ninia/jep/releases/tag/v4.1.0! I'll look into updating it a subsequent PR.

@shamsasari
Copy link
Contributor Author

shamsasari commented Nov 3, 2022

This also highlights the problem with the current approach where we take a dependency to Jep via maven (a specific version), but then install the native libs for it via apt-get. Rather than figuring out if they are compatible with each other, we should use the same source for both, which probably means that we will need to build Jep ourselves and bundle the jep .so with the SDK.

@shamsasari shamsasari marked this pull request as draft November 4, 2022 07:50
Copy link
Contributor

@bon000 bon000 left a comment

Choose a reason for hiding this comment

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

A first look with some questions. Good stuff

@shamsasari shamsasari marked this pull request as ready for review November 4, 2022 14:55
@shamsasari
Copy link
Contributor Author

Comments addressed, PTAL.

Copy link
Contributor

@bon000 bon000 left a comment

Choose a reason for hiding this comment

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

Another set of minor requests. Will still need to see the changes in Gradle Plugin

@shamsasari
Copy link
Contributor Author

Pushed out another attempt to fix the integration tests. Also responded to your comments.

@shamsasari
Copy link
Contributor Author

The integration tests are now working.

…ine, however this not a behaviour we actually want, so can be removed. But, the test shouldn't be hanging, which implies something is wrong with the Gramine integration. The test is reentract on a lock during close(), so perhaps that's where the issue might be. Either way, that's an issue for later.
… in Gramine, however this not a behaviour we actually want, so can be removed. But, the test shouldn't be hanging, which implies something is wrong with the Gramine integration. The test is reentract on a lock during close(), so perhaps that's where the issue might be. Either way, that's an issue for later."

This reverts commit fd648a0.
@shamsasari
Copy link
Contributor Author

I've fixed the integration tests for gramine so that now they don't hang. We get most, but not all, of the tests running.

@github-actions github-actions bot merged commit 3b7025e into master Nov 7, 2022
@github-actions github-actions bot deleted the shams-jep-gramine branch November 7, 2022 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants