Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pins/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,12 @@ def prepare_pin_version(self, pin_dir_path, x, name: "str | None", *args, **kwar
# TODO(compat): set display none in index.html
context["data_preview"] = json.dumps({})

# do not show r code if not round-trip friendly
if meta.type in ["joblib"]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

type options are "csv", "arrow", "parquet", "joblib", or "json". we will hide the R code if the pin is of joblib type

context["show_r_style"] = "display:none"
else:
context["show_r_style"] = ""

# render html template ----

from jinja2 import Environment
Expand Down
14 changes: 13 additions & 1 deletion pins/rsconnect/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<h3>{{pin_name}}</h3>
{% if pin_metadata %}
<p>
{% if date %}<b>Last updated:</b> {{ date }} &bull;{% endif %}
{% if date %}<b>Last updated from Python:</b> {{ date }} &bull;{% endif %}
<b>Format:</b> {{ pin_metadata.type }} &bull;
<b>API:</b> v{{ pin_metadata.api_version }}
</p>
Expand All @@ -50,15 +50,27 @@ <h3>{{pin_name}}</h3>
<h3>Python Code</h3>

<pre id="pin-python" class="pin-code"><code class="python">from pins import board_connect
from dotenv import load_dotenv
load_dotenv()

board = {{board_deparse}}
board.pin_read("{{pin_name}}")</code></pre>

<script type="text/javascript">
hljs.registerLanguage("python", highlight_python);
hljs.registerLanguage("r", highlight_r);
hljs.initHighlightingOnLoad();
</script>
</section>

<section style="{{ show_r_style }}">
<h3>R Code</h3>
<pre id="pin-r" class="pin-code"><code class="r">library(pins)

board <- board_connect(auth = "envvar")
pin_read(board, "{{pin_name}}")</code></pre>
</section>

<section style="{{ data_preview_style }}">
<h3>Preview <small>(up to 100 rows)</small></h3>
<div data-pagedtable style="height: 25em;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<h3>derek/test_rsc_pin</h3>

<p>
<b>Last updated:</b> 2020-01-13 23:58:59 &bull;
<b>Last updated from Python:</b> 2020-01-13 23:58:59 &bull;
<b>Format:</b> csv &bull;
<b>API:</b> v1
</p>
Expand All @@ -59,15 +59,27 @@ <h3>derek/test_rsc_pin</h3>
<h3>Python Code</h3>

<pre id="pin-python" class="pin-code"><code class="python">from pins import board_connect
from dotenv import load_dotenv
load_dotenv()

board = board_connect(server_url='http://localhost:3939')
board.pin_read("derek/test_rsc_pin")</code></pre>

<script type="text/javascript">
hljs.registerLanguage("python", highlight_python);
hljs.registerLanguage("r", highlight_r);
hljs.initHighlightingOnLoad();
</script>
</section>

<section style="">
<h3>R Code</h3>
<pre id="pin-r" class="pin-code"><code class="r">library(pins)

board <- board_connect(auth = "envvar")
pin_read(board, "derek/test_rsc_pin")</code></pre>
</section>

<section style="">
<h3>Preview <small>(up to 100 rows)</small></h3>
<div data-pagedtable style="height: 25em;">
Expand Down