_post = _getpost('https://outerbounds.com/wp-json/wp/v2/posts/220') assert _post _post = _getpost(post_id=247, baseurl='https://outerbounds.com/wp-json/wp/v2/posts') #this is an alternate way of calling this assert _post
WP object will allow you to get access to useful properties that can render as front matter.
_post = WP('https://outerbounds.com/blog/notebooks-in-production-with-metaflow/') print(_post.frontmatter)
--- title: "Notebooks In Production With Metaflow" date: "2022-02-09T22:59:06" image: "https://outerbounds.com/wp-content/uploads/2022/02/Screen-Shot-2022-02-09-at-12.45.20-pm-1024x525.png" slug: "notebooks-in-production-with-metaflow" ---
_result="""--- title: "Notebooks In Production With Metaflow" date: "2022-02-09T22:59:06" image: "https://outerbounds.com/wp-content/uploads/2022/02/Screen-Shot-2022-02-09-at-12.45.20-pm-1024x525.png" slug: "notebooks-in-production-with-metaflow" --- """ test_eq(_post.frontmatter, _result)
The markdown representation is also available as a property (below we print the first 1,000 characters:
--- title: "Notebooks In Production With Metaflow" date: "2022-02-09T22:59:06" image: "https://outerbounds.com/wp-content/uploads/2022/02/Screen-Shot-2022-02-09-at-12.45.20-pm-1024x525.png" slug: "notebooks-in-production-with-metaflow" --- By Hamel Husain *Learn how to use notebooks in production ML workflows with a new Metaflow feature* When building production-ready machine learning systems, it is critical to monitor the health and performance of those systems with reports and visualizations. Furthermore, allowing for rapid debugging and interactive introspection is critical when workflows fail or do unexpected things. Jupyter notebooks have often been a preferred tool of data scientists for these tasks of visualization, exploration, debugging, and rapid iteration. Ironically, many production systems do not integrate appropriately with notebooks, which can significantly frustrate progress on these tasks. Indeed, in the field of data science tooling, one of the most [hotly-contested](https://mlops.community/jupyter-notebooks-in-production/) questions is whether notebooks are suitable for production use. We believe that tools should strive to meet data scientists where they are instead of forcing them to adapt approaches from other disciplines not suited to their needs. This is why we are excited to introduce **Notebook Cards**, which allow data scientists to use notebooks for visualizing and debugging production workflows and help to bridge the MLOps divide between
A wordpress post may note be public (i.e. it might have a status other than
published). In that case, you will need two pieces of information to retrieve the markdown content for that post.
The url for the api. This is
<your_site>/wp-json/v2/posts, for example
https://outerbounds.com/wp-json/wp/v2/posts. Note: This is the api route to retrieve a single WP post.
post idyou wish to convert to markdown. The post id can be extracted from wordpress edit url, for example the id for
For example, we can get the contets of a post which has an id of
220 as follows:
_post = WP(baseurl='https://outerbounds.com/wp-json/wp/v2/posts', post_id=220) test_eq(_post.title, 'Notebooks In Production With Metaflow')
assert len(_post.mdimages) == 5
_post.tomd() _data_dir = Path('_notebooks-in-production-with-metaflow_data/') assert _data_dir.exists() _data_dir.ls()
The paths to downloaded images are also automatically replaced in the markdown file:
_md = Path('notebooks-in-production-with-metaflow.md').read_text() _img_url=r'https://lh4.googleusercontent.com/-8XLZezB4E7s64BQcu-KTZO0VWh4VyKXpNhVwzSqPSgrAC_3qu62OZ-fleSr5mGRqPYTcEm5ed_ZKx8o6W0o2JIQea1kCemhuX5cZMMZRRtumGi0yf0mIp3DJWvDzKGpUR9GP8ug' assert _img_url in _post.raw_markdown assert _img_url not in _md
url_or_id:"the public URL of the WP article OR the post id",
apiurl:"the base url for the wordpress api to retrieve posts for your site."=
dest_path:"The path to save the markdown file to"=
dest_file:"Name of destination markdown file. If not given defaults to the slug indicated in wordpress"=
no_download:"Pass this flag to NOT download any images locally"=
Convert A wordpress post into markdown file with front matter.