Skip to content

Commit

Permalink
adding rmd support
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyBRoswell committed Jul 23, 2024
1 parent eac72b8 commit b7550c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion vreapis/containerizer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import jsonschema
from slugify import slugify
from github import Github, UnknownObjectException
import jupytext

from catalog.serializers import CellSerializer
from containerizer.RContainerizer import RContainerizer
Expand Down Expand Up @@ -88,9 +89,15 @@ def get(self, request: Request):
def post(self, request: Request):
payload = request.data
common.logger.debug('ExtractorHandler. payload: ' + json.dumps(payload, indent=4))
if 'rmarkdown' in payload:
Rmd = jupytext.reads(payload['rmarkdown'], fmt='Rmd')
ipynb = jupytext.writes(Rmd, fmt='ipynb')
payload['notebook'] = ipynb
kernel = payload['kernel']
cell_index = payload['cell_index']
notebook = nbformat.reads(json.dumps(payload['notebook']), nbformat.NO_CONVERT)
if isinstance(payload['notebook'], dict):
payload['notebook'] = json.dumps(payload['notebook'])
notebook = nbformat.reads(payload['notebook'], nbformat.NO_CONVERT)

source = notebook.cells[cell_index].source

Expand Down
1 change: 1 addition & 0 deletions vreapis/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ pytype
autopep8
distro
pygithub
jupytext

0 comments on commit b7550c0

Please sign in to comment.