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

docs: Added Dash example. #76

Merged
merged 3 commits into from
Mar 6, 2024
Merged

docs: Added Dash example. #76

merged 3 commits into from
Mar 6, 2024

Conversation

plascaray
Copy link
Collaborator

No description provided.

Copy link

github-actions bot commented Mar 5, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
282 246 87% 80% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: bbd951e by action🐍

Comment on lines +42 to +43
session_token = flask.request.headers.get('Posit-Connect-User-Session-Token')
credentials_provider = viewer_credentials_provider(user_session_token=session_token)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see a pattern like this in all of the examples, and I wonder if we can wrap this up more. Can we have a single function that detects, or try/excepts, to get the header from the places where shiny/flask/etc. put it? (Tangentially related: #54)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've had the same thought. I think that would be a nice addition. We'll need to follow the same pattern we did with pandas to avoid having our SDK depend on each of the frameworks.

try:
  import flask
except ImportError:
  return None

It also varies quite a bit depending on the framework. For flask/fastapi, the headers are on the incoming request object. For shiny it's on the session which is only available in the server block. We'll have to experiment with each of the frameworks more to see what feels like the right interface for this helper.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For shiny it's on the session which is only available in the server block

Slighly complicated further by the fact that Shiny Express doesn't have a server block. But still, may be worth exploring.

To publish, make sure `CONNECT_SERVER`, `CONNECT_API_KEY`, `DATABRICKS_HOST`, `DATABRICKS_PATH` have valid values. Then, on a terminal session, enter the following command:

```bash
rsconnect deploy shiny . \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
rsconnect deploy shiny . \
rsconnect deploy dash . \

Should this be dash here?

The Databricks environment variables only need to be set once, unless a change needs to be made. If the values have not changed, you don’t need to provide them again when you publish updates to the document.

```
rsconnect deploy shiny . \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
rsconnect deploy shiny . \
rsconnect deploy dash . \

Same as above?

## Start the app locally

```bash
python app.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should talk about the required environment variables before we show how to run the app. This fails if the user hasn't set DATABRICKS_HOST and DATABRICKS_PATH in their shell

@dbkegley dbkegley merged commit ac59e79 into main Mar 6, 2024
8 checks passed
@dbkegley dbkegley deleted the pbl-examples-dash branch March 6, 2024 17:52
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.

4 participants