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

Allow server-side panel code on S3 #1089

Merged
merged 5 commits into from
Nov 15, 2024

Conversation

forman
Copy link
Member

@forman forman commented Nov 15, 2024

The code for server-side panels can now also be loaded from S3. For example:

base_dir: "s3://xcube-testing"

Viewer:
  Augmentation:
    Path: "viewer/extensions"
    Extensions:
      - my_ext.ext

In addition, the xcube test helper module test.s3test has been enhanced to support testing the experimental server-side panels described above:

  • added new decorator @s3_test() for individual tests with timeout arg;
  • added new context manager s3_test_server() with timeout arg to be used within tests function bodies;
  • S3Test, @s3_test(), and s3_test_server() now restore environment variables modified for the Moto S3 test server.

Checklist:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • [ ] New/modified features documented in docs/source/*
  • Changes documented in CHANGES.md
  • GitHub CI passes
  • AppVeyor CI passes
  • Test coverage remains or increases (target 100%)

@forman forman self-assigned this Nov 15, 2024
@forman forman marked this pull request as ready for review November 15, 2024 13:12
@forman forman requested a review from TejasMorbagal November 15, 2024 13:13
Copy link
Contributor

@TejasMorbagal TejasMorbagal left a comment

Choose a reason for hiding this comment

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

Tried to test it on the dev deployment, still doesn't work

[I 2024-11-15 13:53:39,345 xcube] Applying initial configuration...
[W 2024-11-15 13:53:39,348 xcube] Downloading s3://xcube-viewer-app/bc/dev to /tmp/xcube-viewer-aux-utjgj30v
[W 2024-11-15 13:53:39,722 xcube] Temporarily prepending '/tmp/xcube-viewer-aux-utjgj30v' to sys.path
[I 2024-11-15 13:53:39,722 xcube] Loading viewer extension(s) my_viewer_ext.ext
[I 2024-11-15 13:53:39,723 xcube] Restored sys.path
[E 2024-11-15 13:53:39,723 xcube] Internal error: No module named 'my_viewer_ext'
Traceback (most recent call last):
File "/opt/conda/lib/python3.12/site-packages/xcube/cli/main.py", line 87, in main
exit_code = cli.main(args=args, obj=ctx_obj, standalone_mode=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/xcube/cli/serve.py", line 251, in serve
server = Server(framework, config)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/xcube/server/server.py", line 97, in init
ctx.on_update(None)
File "/opt/conda/lib/python3.12/site-packages/xcube/server/server.py", line 511, in on_update
next_api_ctx.on_update(prev_api_ctx)
File "/opt/conda/lib/python3.12/site-packages/xcube/webapi/viewer/context.py", line 41, in on_update
self.set_extension_context(path, extension_refs)
File "/opt/conda/lib/python3.12/site-packages/xcube/webapi/viewer/context.py", line 76, in set_extension_context
self.ext_ctx = ExtensionContext.load(self.server_ctx, extension_refs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/chartlets/extensioncontext.py", line 58, in load
module = importlib.import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1324, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'my_viewer_ext'

the my_viewer_ext exists on s3.

@forman
Copy link
Member Author

forman commented Nov 15, 2024

[W 2024-11-15 13:53:39,348 xcube] Downloading s3://xcube-viewer-app/bc/dev to /tmp/xcube-viewer-aux-utjgj30v
[W 2024-11-15 13:53:39,722 xcube] Temporarily prepending '/tmp/xcube-viewer-aux-utjgj30v' to sys.path

s3://xcube-viewer-app/bc/dev seems to be empty.

@TejasMorbagal
Copy link
Contributor

Tested and it works now!

@TejasMorbagal TejasMorbagal merged commit d11e2ba into main Nov 15, 2024
2 of 3 checks passed
@TejasMorbagal TejasMorbagal deleted the forman-x-fix_importing_server_side_contribs branch November 15, 2024 15:39
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.

2 participants