Related
I obtain the following error when typing mkdocs serve in terminal:
ERROR - Error reading page 'codereference.md': <class '_ast.ExtSlice'>
(with a very long traceback, see below)
My mkdocs.yaml file is:
site_name: Code Documentation
site_url: https://example.com/
nav:
- Home: index.md
- About: about.md
- Code: codereference.md
theme: readthedocs
plugins:
- mkdocstrings:
handlers:
python:
paths: [.]
The codereference.md file consists of the following:
# Reference
::: path.to.class.from.where.mkdocsyaml.is
Anybody have any possible answers?
The full traceback is:
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/__main__.py", line 181, in serve_command
serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/serve.py", line 63, in serve
config = builder()
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/serve.py", line 58, in builder
build(config, live_server=live_server, dirty=dirty)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/build.py", line 292, in build
_populate_page(file.page, config, files, dirty)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/build.py", line 174, in _populate_page
page.render(config, files)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/structure/pages.py", line 175, in render
self.content = md.convert(self.markdown)
File "/usr/local/lib/python3.8/dist-packages/markdown/core.py", line 264, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/usr/local/lib/python3.8/dist-packages/markdown/blockparser.py", line 90, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/usr/local/lib/python3.8/dist-packages/markdown/blockparser.py", line 105, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/usr/local/lib/python3.8/dist-packages/markdown/blockparser.py", line 123, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/usr/local/lib/python3.8/dist-packages/mkdocstrings/extension.py", line 121, in run
html, handler, data = self._process_block(identifier, block, heading_level)
File "/usr/local/lib/python3.8/dist-packages/mkdocstrings/extension.py", line 195, in _process_block
data: CollectorItem = handler.collect(identifier, options)
File "/usr/local/lib/python3.8/dist-packages/mkdocstrings_handlers/python/handler.py", line 191, in collect
loader.load_module(module_name)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 148, in load_module
top_module = self._load_module(package.name, package.path, submodules=submodules)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 352, in _load_module
return self._load_module_path(module_name, module_path, submodules, parent)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 380, in _load_module_path
self._load_submodules(module)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 385, in _load_submodules
self._load_submodule(module, subparts, subpath)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 396, in _load_submodule
member_parent[subparts[-1]] = self._load_module(
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 352, in _load_module
return self._load_module_path(module_name, module_path, submodules, parent)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 374, in _load_module_path
module = self._visit_module(code, module_name, module_path, parent)
File "/usr/local/lib/python3.8/dist-packages/griffe/loader.py", line 413, in _visit_module
module = visit(
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 92, in visit
return Visitor(
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 172, in get_module
self.visit(top_node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 183, in visit
super().visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/base.py", line 19, in visit
getattr(self, f"visit_{node.kind}", self.generic_visit)(node) # type: ignore[attr-defined]
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 214, in visit_module
self.generic_visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 196, in generic_visit
self.visit(child)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 183, in visit
super().visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/base.py", line 19, in visit
getattr(self, f"visit_{node.kind}", self.generic_visit)(node) # type: ignore[attr-defined]
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 255, in visit_classdef
self.generic_visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 196, in generic_visit
self.visit(child)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 183, in visit
super().visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/base.py", line 19, in visit
getattr(self, f"visit_{node.kind}", self.generic_visit)(node) # type: ignore[attr-defined]
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 451, in visit_functiondef
self.handle_function(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 442, in handle_function
self.generic_visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 196, in generic_visit
self.visit(child)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 183, in visit
super().visit(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/base.py", line 19, in visit
getattr(self, f"visit_{node.kind}", self.generic_visit)(node) # type: ignore[attr-defined]
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 589, in visit_assign
self.handle_attribute(node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/visitor.py", line 548, in handle_attribute
value = get_value(node.value) # type: ignore[arg-type]
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/nodes.py", line 1181, in get_value
return _node_value_map[type(node)](node)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/nodes.py", line 1047, in _get_subscript_value
subscript = _get_value(node.slice)
File "/usr/local/lib/python3.8/dist-packages/griffe/agents/nodes.py", line 1167, in _get_value
return _node_value_map[type(node)](node)
KeyError: <class '_ast.ExtSlice'>
It's fixed in version 0.21.0 of Griffe: https://mkdocstrings.github.io/griffe/changelog/#bug-fixes
It would previously crash when unparsing values using extended slices such as o[x:y,z].
I am trying to access a table in an AWS bucket. When I try to access it using awswrangler.read_parquet function I get an error saying that I am not able to access that file because I can't create new threads. I am usually able to access that file after waiting 30min+, but that doesn't tell me how to solve the problem. Here are more details about the command:
aws_df = wr.s3.read_parquet(path=self._filepath, **self._load_args)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_read_parquet.py", line 721, in read_parquet
read_func=_read_parquet, paths=paths, version_ids=versions, use_threads=use_threads, kwargs=args
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_read.py", line 145, in _read_dfs_from_multiple_paths
return list(df for df in executor.map(partial_read_func, paths, versions))
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_read.py", line 145, in <genexpr>
return list(df for df in executor.map(partial_read_func, paths, versions))
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 586, in result_iterator
yield fs.pop().result()
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_read_parquet.py", line 495, in _read_parquet
version_id=version_id,
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_read_parquet.py", line 440, in _read_parquet_file
source=f, read_dictionary=categories
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_read_parquet.py", line 40, in _pyarrow_parquet_file_wrapper
return pyarrow.parquet.ParquetFile(source=source, read_dictionary=read_dictionary)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/pyarrow/parquet.py", line 201, in __init__
read_dictionary=read_dictionary, metadata=metadata)
File "pyarrow/_parquet.pyx", line 1021, in pyarrow._parquet.ParquetReader.open
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_fs.py", line 569, in read
self._fetch(self._loc, self._loc + length)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_fs.py", line 376, in _fetch
self._cache = self._fetch_range_proxy(self._start, self._end)
File "/home/ec2-user/anaconda3/lib/python3.7/site-packages/awswrangler/s3/_fs.py", line 359, in _fetch_range_proxy
itertools.repeat(self._version_id),
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 575, in map
fs = [self.submit(fn, *args) for args in zip(*iterables)]
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 575, in <listcomp>
fs = [self.submit(fn, *args) for args in zip(*iterables)]
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/thread.py", line 160, in submit
self._adjust_thread_count()
File "/home/ec2-user/anaconda3/lib/python3.7/concurrent/futures/thread.py", line 181, in _adjust_thread_count
t.start()
File "/home/ec2-user/anaconda3/lib/python3.7/threading.py", line 847, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
I was able to solve the problem by adding a sleep between my commands.
import time
time.sleep(10)
when i want to convert my keras model en2.h5 into a tflite model encoder.tflite, i input below into my terminal
tflite_convert --output_file=/Users/yixun/Downloads/untitled/encoder.tflite \--keras_model_file=/Users/yixun/Downloads/untitled/en2.h5 --output_format=TFLITE
But the following error returns:
Traceback (most recent call last):
File "/Users/yixun/anaconda3/bin/tflite_convert", line 11, in <module>
sys.exit(main())
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/lite/python/tflite_convert.py", line 515, in main
app.run(main=run_main, argv=sys.argv[:1])
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/Users/yixun/anaconda3/lib/python3.7/site-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/Users/yixun/anaconda3/lib/python3.7/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/lite/python/tflite_convert.py", line 502, in run_main
_convert_tf2_model(tflite_flags)
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/lite/python/tflite_convert.py", line 217, in _convert_tf2_model
model = keras.models.load_model(flags.keras_model_file)
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/save.py", line 146, in load_model
return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 168, in load_model_from_hdf5
custom_objects=custom_objects)
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/model_config.py", line 55, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/serialization.py", line 102, in deserialize
printable_module_name='layer')
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/utils/generic_utils.py", line 191, in deserialize_keras_object
list(custom_objects.items())))
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py", line 906, in from_config
config, custom_objects)
File "/Users/yixun/.local/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py", line 1874, in reconstruct_from_config
layer_output_tensors = layer._inbound_nodes[node_index].output_tensors
TypeError: list indices must be integers or slices, not NoneType
what should i do?
I have created a custom environment for reinforcement learning with tf-agents (not needed to answer this question), which works fine if I instantiate one thread by setting num_parallel_environments to 1, but throws infrequent and seemingly random errors like an IndexError inside random.shuffle(), when I increase num_parallel_environments to 50. Here's the code:
inside train.py
tf_env = tf_py_environment.TFPyEnvironment(
batched_py_environment.BatchedPyEnvironment(
[environment.CardGameEnv()] * num_parallel_environments))
inside my environment, this is run in threads
self.cardStack = getFullDeck()
random.shuffle(self.cardStack)
this is a normal function, imported in every thread class
def getFullDeck():
deck = []
for rank in Ranks:
for suit in Suits:
deck.append(Card(rank, suit))
return deck
And here's one of the possible errors:
Traceback (most recent call last):
File "e:\Users\tmp\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\ptvsd_launcher.py", line 45, in <module>
main(ptvsdArgs)
File "e:\Users\tmp\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\__main__.py", line 348, in main
run()
File "e:\Users\tmp\.vscode\extensions\ms-python.python-2019.1.0\pythonFiles\lib\python\ptvsd\__main__.py", line 253, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Python37\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Python37\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "e:\Users\tmp\Documents\Programming\Neural Nets\Poker_AI\train_v2.py", line 320, in <module>
app.run(main)
File "C:\Python37\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\Python37\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "e:\Users\tmp\Documents\Programming\Neural Nets\Poker_AI\train_v2.py", line 315, in main
num_eval_episodes=FLAGS.num_eval_episodes)
File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\gin\config.py", line 1032, in wrapper
utils.augment_exception_message_and_reraise(e, err_str)
File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\gin\utils.py", line 49, in augment_exception_message_and_reraise
six.raise_from(proxy.with_traceback(exception.__traceback__), None)
File "<string>", line 3, in raise_from
File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\gin\config.py", line 1009, in wrapper
return fn(*new_args, **new_kwargs)
File "e:\Users\tmp\Documents\Programming\Neural Nets\Poker_AI\train_v2.py", line 251, in train_eval
collect_driver.run()
File "C:\Python37\lib\site-packages\tf_agents\drivers\dynamic_episode_driver.py", line 149, in run
maximum_iterations=maximum_iterations)
File "C:\Python37\lib\site-packages\tf_agents\utils\common.py", line 111, in with_check_resource_vars
return fn(*fn_args, **fn_kwargs)
File "C:\Python37\lib\site-packages\tf_agents\drivers\dynamic_episode_driver.py", line 180, in _run
name='driver_loop'
File "C:\Python37\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 2457, in while_loop_v2
return_same_structure=True)
File "C:\Python37\lib\site-packages\tensorflow\python\ops\control_flow_ops.py", line 2689, in while_loop
loop_vars = body(*loop_vars)
File "C:\Python37\lib\site-packages\tf_agents\drivers\dynamic_episode_driver.py", line 103, in loop_body
next_time_step = self.env.step(action_step.action)
File "C:\Python37\lib\site-packages\tf_agents\environments\tf_environment.py", line 232, in step
return self._step(action)
File "C:\Python37\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 232, in graph_wrapper
return func(*args, **kwargs)
File "C:\Python37\lib\site-packages\tf_agents\environments\tf_py_environment.py", line 218, in _step
_step_py, flat_actions, self._time_step_dtypes, name='step_py_func')
File "C:\Python37\lib\site-packages\tensorflow\python\ops\script_ops.py", line 488, in numpy_function
return py_func_common(func, inp, Tout, stateful=True, name=name)
File "C:\Python37\lib\site-packages\tensorflow\python\ops\script_ops.py", line 452, in py_func_common
result = func(*[x.numpy() for x in inp])
File "C:\Python37\lib\site-packages\tf_agents\environments\tf_py_environment.py", line 203, in _step_py
self._time_step = self._env.step(packed)
File "C:\Python37\lib\site-packages\tf_agents\environments\py_environment.py", line 174, in step
self._current_time_step = self._step(action)
File "C:\Python37\lib\site-packages\tf_agents\environments\batched_py_environment.py", line 140, in _step
zip(self._envs, unstacked_actions))
File "C:\Python37\lib\multiprocessing\pool.py", line 268, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Python37\lib\multiprocessing\pool.py", line 657, in get
raise self._value
File "C:\Python37\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "C:\Python37\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(*args))
File "C:\Python37\lib\site-packages\tf_agents\environments\batched_py_environment.py", line 139, in <lambda>
lambda env_action: env_action[0].step(env_action[1]),
File "C:\Python37\lib\site-packages\tf_agents\environments\py_environment.py", line 174, in step
self._current_time_step = self._step(action)
File "e:\Users\tmp\Documents\Programming\Neural Nets\Poker_AI\environment.py", line 116, in _step
canRoundContinue = self._table.runUntilChoice(action)
File "e:\Users\tmp\Documents\Programming\Neural Nets\Poker_AI\table.py", line 326, in runUntilChoice
random.shuffle(self.cardStack)
File "C:\Python37\lib\random.py", line 278, in shuffle
x[i], x[j] = x[j], x[i]
IndexError: list index out of range
In call to configurable 'train_eval' (<function train_eval at 0x000002722713A158>)
I suspect this error occurs because the threads are changing the array simultaneously, but I do not see why this would be the case:
Everything happens inside a class instance and the array getFullDeck() is returning is recreated every time the function is called, so there should be no way multiple threads have access to the same reference, right?
tf_env = tf_py_environment.TFPyEnvironment(
batched_py_environment.BatchedPyEnvironment(
[environment.CardGameEnv()] * num_parallel_environments))
You are reusing the same environment for each of the parallel instances rather than creating a new environment for each one. You might want to try something like
tf_env = tf_py_environment.TFPyEnvironment(
batched_py_environment.BatchedPyEnvironment(
[environment.CardGameEnv() for _ in range(num_parallel_environments)]))
File "C:\ProgramData\Anaconda3\Scripts\tensorboard-script.py", line 10, in
sys.exit(run_main())
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\main.py", line 57, in run_main
app.run(tensorboard.main, flags_parser=tensorboard.configure)
File "C:\ProgramData\Anaconda3\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\program.py", line 228, in main
self._register_info(server)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\program.py", line 274, in _register_info
manager.write_info_file(info)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\manager.py", line 269, in write_info_file
payload = "%s\n" % _info_to_string(tensorboard_info)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\manager.py", line 129, in _info_to_string
for k in _TENSORBOARD_INFO_FIELDS
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\manager.py", line 129, in
for k in _TENSORBOARD_INFO_FIELDS
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorboard\manager.py", line 51, in
(dt - datetime.datetime.fromtimestamp(0)).total_seconds()),
OSError: [Errno 22] Invalid argument
is your tensorboard 1.13.1?
if so,make it come to 1.12.1,solved the problem.
but i can't find out the reason.