Are Explicit Tags in mkdocs config supported in readthedocs? - read-the-docs

I've been working on writing some mkdocs documentation which includes mermaid diagrams that I'd like to keep in the markdown files instead of turning into images and embedding them
I came across this great solution here: https://github.com/squidfunk/mkdocs-material/issues/693#issuecomment-411885426
Which uses the super-fences feature of the pymdown-extensions plugin to create a custom code block which renders the mermaid diagrams inside the code block.
It works in mkdocs running locally, but when I submit the configuration file to readthedocs it fails the yaml validation
Your mkdocs.yml could not be loaded, possibly due to a syntax error (line 18, column 19)
Line 18 in the mkdocs.yml config file is the section which calls the superfences python class
format: !!python/name:pymdownx.superfences.fence_div_format
Looking in the yaml specification https://yaml.org/spec/1.2/spec.html Shows that !! is for an explicit tag and it seems to have been part of the spec for quite some time ( back to version 1). I've tried making the value a string but this then causes issue with python reading it as a string
Does anyone know if readthedocs supports this or have you been able to get this working some other way?

ReadTheDocs is parsing the mkdocs.yaml file using pyyaml and it seems that it does not recognize !!.
For example:
>>> import yaml
>>> document = """
a: 1
b:
c: 3
d: !!4
"""
>>> print(yaml.dump(yaml.load(document)))
<stdin>:1: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
return loader.get_single_data()
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 51, in get_single_data
return self.construct_document(node)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 60, in construct_document
for dummy in generator:
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 413, in construct_yaml_map
value = self.construct_mapping(node)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 218, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 143, in construct_mapping
value = self.construct_object(value_node, deep=deep)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 100, in construct_object
data = constructor(self, node)
File "/usr/lib/python3.8/site-packages/yaml/constructor.py", line 427, in construct_undefined
raise ConstructorError(None, None,
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:4'
in "<unicode string>", line 5, column 8:
d: !!4
^
>>>
See: https://github.com/readthedocs/readthedocs.org/issues/6889

Related

Brownie Errors when attempting to compile

When I type "brownie compile" it doesn't work and I get this error. Anybody know why?
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\_cli\__main__.py", line 64, in main
importlib.import_module(f"brownie._cli.{cmd}").main()
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\_cli\compile.py", line 50, in main
proj = project.load()
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 750, in load
return Project(name, project_path)
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 182, in __init__
self.load()
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 237, in load
self._compile(changed, self._compiler_config, False)
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 89, in _compile
_install_dependencies(self._path)
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 756, in _install_dependencies
install_package(package_id)
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 778, in install_package
return _install_from_github(package_id)
File "c:\users\sircr\appdata\local\programs\python\python39\lib\site-packages\brownie\project\main.py", line 851, in _install_from_github
raise ConnectionError(msg)
ConnectionError: Status 404 when getting package versions from Github: 'Not Found'
check your config file, it mostly gives an error due to typos. in my file i had written the dependency right after the hyphen(-) without any space and when i fixed it the contract was compiled properly
brownie-config.yaml file before solving the error
dependencies:
-smartcontractkit/chainlink-brownie-contracts#1.1.1
brownie-config.yaml file after solving the error
dependencies:
- smartcontractkit/chainlink-brownie-contracts#1.1.1
do the same whenever using an hyphen(-)
It seems you didn't written the right link and also, when you paste the import for the V3 aggregator check the version, I changed V0.8 to V0.6 to be correct with the solidity version 0.6.6
ex: for me, I just added a s at contract to solve the issue.
smartcontractkit/chainlink-brownie-contracts#1.1.1 is ok instead of smartcontractkit/chainlink-brownie-contract#1.1.1 I've written at first (wrongly)
after those changes, it worked perfectly

simplejson json AttributeError: "module" object has no attribute "dump"

I am new at programming and I have a question regarding the following error.
I am using python 2.7., and I have the following script to create a simple graph (example taken from python CrashCourse by Eric Matthes):
import matplotlib.pyplot as plt
squares = [1,4,9,16,25]
plt.plot(squares, linewitdth = 5)
#Set chart title and lable axes.
plt.title("Square Numbers", fontsize = 24)
plt.xlabel("Value", fontsize = 14)
plt.ylabel("Square of Value", fontsize = 14)
# Set size of tick labels
plt.tick_params(axis = "both", labelsize = 14)
plt.show()
When I ran this script in WindowsPowerShell I got the following error:
Traceback (most recent call last): File "mpl_squares.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Users\Roger\Anaconda2\lib\sitepackages\matplotlib\__init__.py, line 134, in <module> from ._version import get_versions
File "C:\Users\Roger\Anaconda2\lib\site-packages\matplotlib\_version.py", line 7, in <module> import json
File "C:\Users\Roger\Desktop\lpthw\json.py", line 7, in <module>
AttributeError: "module" object has no attribute "dump"
In other script I had the same problem when importing this module, then I found
a solution by replacing the line "import json" by "import simplejson, and It worked well.
Here is the solution I found back then:
json is simplejson, added to the stdlib. But since json was added in 2.6, simplejson has the advantage of working on more Python versions (2.4+).
simplejson is also updated more frequently than Python, so if you need (or want) the latest version, it's best to use simplejson itself, if possible.
A good practice, in my opinion, is to use one or the other as a fallback.
try: import simplejson as json
except ImportError: import json
Now I checkt in the error I got the module it is poiting out "_version.py"
This is the information contained in this file:
# This file was generated by 'versioneer.py' (0.15) from
# revision-control system data, or from the parent directory name of an
# unpacked source archive. Distribution tarballs contain a pre-generated
#copy
# of this file.
import json
import sys
version_json = '''
{
"dirty": false,
"error": null,
"full-revisionid": "26382a72ea234ee0efd40543c8ae4a30cffc4f0d",
"version": "1.5.3"
}
''' # END VERSION_JSON
def get_versions():
return json.loads(version_json)
Question:
Do you think I would have to fix something in the _version.py module by replacing
import json for import simplejson and the function added in the module?
I am thinking in a workaround to fix the problem but I don't wanna modify anything from the _version.py if it make things worse. Thank you very much for your comments and suggestions.
Best Regards
It seems like your C:\Users\Roger\Desktop\lpthw\json.py gets imported instead of Python's built-in json module.
Did you somehow add that folder (C:\Users\Roger\Desktop\lpthw) to your PYTHONPATH, e.g. with sys.path.append() or the PYTHONPATH variable? Read more about how Python finds modules.
The reason why the fix with simplejson works is that it is not overridden by some other module of the same name.
Try renaming C:\Users\Roger\Desktop\lpthw\json.py to something like C:\Users\Roger\Desktop\lpthw\myjson.py and also try to figure out how that lpthw folder made it into your PYTHONPATH.

Cause of jinja2.exceptions.TemplateNotFound even when using just jinja2

The cause of the problem is obvious after the fact, but I'd like to share the not-too-obvious cause here.
When running code such as
import jinja2
templateLoader = jinja2.FileSystemLoader(searchpath=".")
templateEnv = jinja2.Environment(loader=templateLoader,
trim_blocks=True,
lstrip_blocks=True)
htmlTemplateFile = 'file.jinja.html'
htmlTemplate = templateEnv.get_template(htmlTemplateFile)
if you get this problem:
Traceback (most recent call last):
...
File "file.py", line xyz, in some_func
htmlTemplate = templateEnv.get_template(htmlTemplateFile)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jinja2/environment.py", line 812, in get_template
return self._load_template(name, self.make_globals(globals))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jinja2/environment.py", line 774, in _load_template
cache_key = self.loader.get_source(self, name)[1]
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/jinja2/loaders.py", line 187, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: file.jinja.html
you may find the discussions online point that this issue must have something to do with the interaction of jinja2 with flask, with GAE, with Pyramid, or with SQL, and it may indeed be that your templates are not in a "template" folder, but this problem can arise from the interaction of jinja2 and the os module.
The culprit is changing the current directory by, for instance,
import os
os.chdir(someDir)
If templateEnv.get_template(...) is called past this point, jinja2 will look for the templates in the "current" dir, even if that has changed.
Since module os provides os.chdir but not os.pushdir/os.popdir, one has to either simulate the latter pair or avoid chdir altogether.

NLTK POS tagset help not working

I downloaded nltk tagset help is not working.
Whenever I try to access tagset meanings by:-
nltk.help.upenn_tagset('NN')
I get result as :-
Traceback (most recent call last):
File "<pyshell#30>", line 1, in <module>
nltk.help.upenn_tagset('NN')
File "C:\Python34\lib\site-packages\nltk\help.py", line 25, in upenn_tagset
_format_tagset("upenn_tagset", tagpattern)
File "C:\Python34\lib\site-packages\nltk\help.py", line 39, in _format_tagset
tagdict = load("help/tagsets/" + tagset + ".pickle")
File "C:\Python34\lib\site-packages\nltk\data.py", line 774, in load
opened_resource = _open(resource_url)
File "C:\Python34\lib\site-packages\nltk\data.py", line 888, in _open
return find(path_, path + ['']).open()
File "C:\Python34\lib\site-packages\nltk\data.py", line 618, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource 'help/tagsets/upenn_tagset.pickle' not found. Please
use the NLTK Downloader to obtain the resource: >>>
nltk.download()
Searched in:
- 'C:\\Users\\aarushi/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Python34\\nltk_data'
- 'C:\\Python34\\lib\\nltk_data'
- 'C:\\Users\\aarushi\\AppData\\Roaming\\nltk_data'
But I already downloaded tagset from models tab by nltk.download()
So what am I doing wrong here?
As nltk is telling you, it searched for the file help/tagsets/upenn_tagset.pickle in the directories:
- 'C:\\Users\\aarushi/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Python34\\nltk_data'
- 'C:\\Python34\\lib\\nltk_data'
- 'C:\\Users\\aarushi\\AppData\\Roaming\\nltk_data'
And could not find it.
Is it there?
If not, use nltk.download() to get it, and make sure it's in one of these directories.
https://i.stack.imgur.com/Ri7E2.png "Reference"
Hi ,
Check for above tagged image to summarize what exactly needs to be downloaded.
One of the fastest and easiest way to resolve this issue by downloading the help_tagsets from nltk.download() .
One can follow below steps:-
open your jupyter notebook or python shell in your OS(thru terminal).
ask for nltk.download() - (shell/jupyter) - it will open the GUI.
search the help_datasets in ALL PACKAGES column.
Just download it :-) Here you go .

Configure Plone to use Relstorage as blobstorage

I have a installation of Plone 4.3.3 with one site. First the buildout was configured to use the Data.fs file in var/filestorage and a shared blob storage in var/blobstorage. Then I added a Relstorage to the buildout and converted the content of the Data.fs file to the underlying MySQL database. Now Plone is using Relstorage instead of Data.fs.
But now I want also to use the Relstorage instead of the blobstorage. Because I am relatively new to Plone and especially the Relstorage thing, my idea was to first setup a new empty Plone. Then I copied the buildout.cfg and base.cfg from the first one to the new one. Then I created a new database userZodb and changed the base.cfg for using the new database and I also changed the ports for zeoserver and clients. The next step was to reconfigure the relstorage for not using the file based blobstorage.
rel-storage =
type mysql
db userZodb
user zodbuser
passwd innzop
blob-dir ${buildout:var-dir}/blobstorage
shared-blob-dir false
# shared blobs are much faster if we're on the same server.
# if not, turn it off.
shared-blob = off
Then I ran the buildout. All was built successfully. After starting the zeoserver, I got this error from the client:
user#server:~/Plone433-dev/zeocluster3$ ./bin/zeoserver start
.
daemon process started, pid=35136
user#server:~/Plone433-dev/zeocluster3$ ./bin/client1 fg
2014-12-17 14:50:31 INFO ZServer HTTP server started at Wed Dec 17 14:50:31 2014
Hostname: 0.0.0.0
Port: 9180
2014-12-17 14:50:32 INFO Products.PloneFormGen gpg_subprocess initialized, using /usr/bin/gpg
Traceback (most recent call last):
File "/home/user/Plone433-dev/zeocluster3/parts/client1/bin/interpreter", line 289, in <module>
exec(compile(__file__f.read(), __file__, "exec"))
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/run.py", line 76, in <module>
run()
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/run.py", line 22, in run
starter.prepare()
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/__init__.py", line 86, in prepare
self.startZope()
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/__init__.py", line 262, in startZope
Zope2.startup()
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/__init__.py", line 47, in startup
_startup()
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/App/startup.py", line 81, in startup
DB = dbtab.getDatabase('/', is_root=1)
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/datatypes.py", line 287, in getDatabase
db = factory.open(name, self.databases)
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/datatypes.py", line 185, in open
DB = self.createDB(database_name, databases)
File "/home/user/Plone433-dev/buildout-cache/eggs/Zope2-2.13.22-py2.7.egg/Zope2/Startup/datatypes.py", line 182, in createDB
return ZODBDatabase.open(self, databases)
File "/home/user/Plone433-dev/buildout-cache/eggs/ZODB3-3.10.5-py2.7-linux-x86_64.egg/ZODB/config.py", line 101, in open
storage = section.storage.open()
File "/home/user/Plone433-dev/buildout-cache/eggs/RelStorage-1.6.0b2-py2.7.egg/relstorage/config.py", line 33, in open
return RelStorage(adapter, name=config.name, options=options)
File "/home/user/Plone433-dev/buildout-cache/eggs/RelStorage-1.6.0b2-py2.7.egg/relstorage/storage.py", line 212, in __init__
self.blobhelper = BlobHelper(options=options, adapter=adapter)
File "/home/user/Plone433-dev/buildout-cache/eggs/RelStorage-1.6.0b2-py2.7.egg/relstorage/blobhelper.py", line 118, in __init__
fshelper.create()
File "/home/user/Plone433-dev/buildout-cache/eggs/ZODB3-3.10.5-py2.7-linux-x86_64.egg/ZODB/blob.py", line 359, in create
(self.layout_name, self.base_dir, layout))
ValueError: Directory layout `zeocache` selected for blob directory /home/user/Plone433-dev/zeocluster3/var/blobstorage/, but marker found for layout `bushy`
Unfortunality I have no idea where the problem could be. Anyone a suggestion?
Thank you!
The solution was to use zodbconvert again. Correctly configured it can convert from one storage to another, for example from Blobstorage to Relstorage. In my case the configuration looks like that:
<filestorage source>
path /home/user/Plone433-dev/zeocluster/var/filestorage/Data20141230.fs
blob-dir /home/user/Plone433-dev/zeocluster/var/blobstorage
</filestorage>
<relstorage destination>
shared-blob-dir false
# ZODB Cache Dir
blob-dir ./var/cacheblob
blob-cache-size 10mb
<mysql>
host localhost
db Zodb
user zodbuser
passwd XXXXXXXXX
</mysql>
</relstorage>
After that you have to change your base.cfg and buildout.cfg for using only relstorage. You can find more information about how exactly it works here: https://www.techidiots.net/notes/plone-1/plone-4-3-3-relstorage
If you're using relstorage the blob directory is still used for caching (Check for more infos). In your case there's a problem with your directory layout.
You can remove the hole var directory in ${buildout:directory} and rerun buildout.
This will create you a new var directory. After starting the instance you should have a new blob directory with the correct layout.
OR
You can modify the .layout file in ${buildout:directory}/var/blobstorage and change the value from bushy to zeocache
Explanation:
The first time you started the Plone instance, it creates the blobstorage directory with the given layout - in your case it was the default bushy. Since you changed the storage it expects zeocache. But the marker file .layout is not changed automatically.
If this doesn't help, please post your full buildout.cfg.