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

Add Python code to Connect preview HTML #806

Merged
merged 7 commits into from
Nov 16, 2023
Merged

Conversation

juliasilge
Copy link
Member

Addresses #796

We discussed a button to switch between the R / Python code, but we need to not show the code at all for .rds pins so I think it's better to just do it with another <section>. This is my current proposal:

Screenshot 2023-11-09 at 6 07 29 PM

You can see a published version here.

@@ -33,7 +33,7 @@
<h3>{{{pin_name}}}</h3>
{{#pin_metadata}}
<p>
{{#date}}<b>Last updated:</b> {{{.}}} &bull;{{/date}}
{{#date}}<b>Last updated from R:</b> {{{.}}} &bull;{{/date}}
Copy link
Member Author

Choose a reason for hiding this comment

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

The Python package can say:

Last updated from Python:

Choose a reason for hiding this comment

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

I like this format for a subtle way to be able to tell what language the data is coming from!

Comment on lines 68 to 70
<pre id="pin-python" class="pin-code"><code class="python">import pins
board = pins.board_connect()
board.pin_read(board, "{{pin_name}}")</code></pre>
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this the best option for Python code? I believe this is what people should use if they are publishing code to Connect, right? Because the env vars are provided?

Copy link

@isabelizimm isabelizimm Nov 14, 2023

Choose a reason for hiding this comment

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

you'll need to bring the environment variables into your session somehow, but once they are there, you won't have to add any special arguments. something like this would work ⏬

import pins
from dotenv import load_dotenv
load_dotenv()

board = pins.board_connect()

@juliasilge juliasilge marked this pull request as ready for review November 10, 2023 01:45
@juliasilge
Copy link
Member Author

You can see the new version of Python code now here.

@juliasilge juliasilge merged commit a3e52c7 into main Nov 16, 2023
14 checks passed
@juliasilge juliasilge deleted the connect-preview-html branch November 16, 2023 17:13
Copy link

github-actions bot commented Dec 1, 2023

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants