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

Implements Tethys Reactpy App Scaffold #1081

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open

Conversation

shawncrawley
Copy link
Contributor

Description

This merge request implements a Tethys ReactPy App scaffold. I will flesh out this description soon with all of the ins and outs of it. I just wanted to finally get this in as a draft pull request to get more eyes on it.

Changes Made to Code:

Related

Additional Notes

Quality Checks

  • [] New code is 100% tested
  • [] Code has been formated
  • [] Code has been linted
  • [] Docstrings for new methods have been added

shawncrawley and others added 8 commits May 13, 2024 20:51
…ike original tethys gizmo

added on_click, on_change, and on_mouse_over kwargs
There were a few bugs found when installing from a fresh test, namely:
* The version of daphne installed by default didn't meet requirements
* There was some experimental reactpy core development that I never
  backed out
@swainn swainn added major feature experimental Experimental features labels Aug 24, 2024
@swainn swainn added this to the Version 4.3 milestone Aug 24, 2024
@coveralls
Copy link

coveralls commented Aug 29, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 8ab53d4 on tethys-reactpy
into d4a8761 on main.

@shawncrawley shawncrawley marked this pull request as ready for review August 29, 2024 23:23
environment.yml Show resolved Hide resolved
In this one instance, Path.exists throws a "File too long" error on Unix
machines, while os.path.exists dose not. I couldn't think of a good
way around that for now.
@shawncrawley
Copy link
Contributor Author

@sdc50 I implemented your feedback. In full disclosure, I got a little carried away when swapping out os.path with pathlib.Path. I ended up removing os.path from the entire project, except for about two spots where pathlib.Path was actually more clunky or problematic. So this PR is definitely super gold-plated by scope creep at this point. That means that there are a lot of new modified files since your last review... I apologize in advance. I was already in too deep before I determined that I shouldn't have added all of that to this specific PR.

tethys_cli/cli_helpers.py Outdated Show resolved Hide resolved
tethys_cli/cli_helpers.py Outdated Show resolved Hide resolved
Copy link
Member

@sdc50 sdc50 left a comment

Choose a reason for hiding this comment

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

@shawncrawley just a couple of minor changes (I've added suggestions that you can just commit if you agree with them).

I'm very excited about the reactpy addition. The Path changes are all internal, but everything is converted back to a string in return values. I think this is the right call for now (to ensure we aren't breaking anything). However, in Tethys 5.0 I think we should switch and return Path objects wherever possible.

shawncrawley and others added 7 commits October 11, 2024 11:33
Adds tests for remaining tethys_component reactpy files
Adds reactpy-django to standard install
Fixes broken support for variable in url for pages
Adds react-loading-overlay and react-map-gl to built-in ComponentLibrary support
Fixes buggy use_workspace
@shawncrawley
Copy link
Contributor Author

@swainn @sdc50 I've got everything done and passing tests except oddly the "Tethys-CI / Conda Build (ubuntu-latest)" test run. Any thoughts there on what could be going on? I have reactpy-django now installed by default, which did throw a wrench in some of the testing. Maybe it's related here? But oddly only this one build...

@shawncrawley
Copy link
Contributor Author

@gagelarsen Do you have any idea on the failing "Conda Build" GitHub workflow?

The authors field cannot be present if name and email
are blank, so they are now conditional upon those
values being filled
@shawncrawley
Copy link
Contributor Author

I know the issue: it's definitely being caused by reactpy-django being added as a pip requirement in the envrionment.yml file (see here). All the more reason to get that package added to conda-forge.

tests/coverage.cfg Outdated Show resolved Hide resolved
environment.yml Show resolved Hide resolved
environment.yml Show resolved Hide resolved
tethys_apps/base/url_map.py Outdated Show resolved Hide resolved
app.root_url = "test-app"

app._registered_url_maps = [
Namespace(name="exclude_page", title="Exclude Page", index=-1),
Copy link
Member

Choose a reason for hiding this comment

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

Why are these argparse.Namespaces? Seems like they should be simple dicts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just wanted a mock-like instance of UrlMap... I should have just used a mock.MagicMock object, lol. I'll swap it for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out I must've chosen Namespace for a reason. Using mock.MagicMock causes the tests to fail because mocking the property name cannot be done on initialization (see mock docs). While I could have broken it out into two steps, it seemed like using Namespace shouldn't be a big deal. Let me know if you disagree.

Copy link
Member

Choose a reason for hiding this comment

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

Try using the UrlMaps for the test instead of the Namespace.

tethys_sdk/components/utils.py Outdated Show resolved Hide resolved
tethys_apps/templates/tethys_apps/reactpy_base.html Outdated Show resolved Hide resolved
shawncrawley and others added 4 commits October 22, 2024 13:42
- pyproject.toml added to all scaffolds
- reactpy_base.html refactored to extend app_base.html
- minor cleanups and refactors
- Reverted last commit's swap of argparse.Namespace for mock.MagicMock since mock requires the "name" argument, which isn't allowed by MagicMock on initialization
- Added reactpy to dependencies in environment.yml
@shawncrawley
Copy link
Contributor Author

It looks like the only thing that remains is getting reactpy and reactpy-django added to conda-forge. I found that we'd also have to add reactpy-router, which unfortunately doesn't have an sdist file (required, I believe, by conda-forge). But I reached out to the reactpy maintainers and they quickly responded that they'll get the sdist file added by tomrorow. Once that's done, I should be able to submit the PR to the conda staged-recipes repo and get those added. It's the final stretch!

Copy link
Member

@swainn swainn left a comment

Choose a reason for hiding this comment

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

Approve, barring conda package and all comments addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental Experimental features major feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants