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].
Related
There is only one categorical column and I want to encode it, it is working fine on notebook but when it is being uploaded to aicrowd platform it is creating this trouble.
There are totally 3 categorical features where one is the target feature, one is the row of ids and after excluding them for the training I am left with one feature.
df[['intersection_pos_rel_centre']]
from sklearn.preprocessing import LabelEncoder
le=LabelEncoder()
df[['intersection_pos_rel_centre']]=le.fit_transform(df[['intersection_pos_rel_centre']])
df[['intersection_pos_rel_centre']]
My error is
Selecting runtime language: python
[NbConvertApp] Converting notebook predict.ipynb to notebook
[NbConvertApp] Executing notebook with kernel: python
Traceback (most recent call last):
File "/opt/conda/bin/jupyter-nbconvert", line 11, in <module>
sys.exit(main())
File "/opt/conda/lib/python3.8/site-packages/jupyter_core/application.py", line 254, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.start()
File "/opt/conda/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 350, in start
self.convert_notebooks()
File "/opt/conda/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 524, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 489, in convert_single_notebook
output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 418, in export_single_notebook
output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 181, in from_filename
return self.from_file(f, resources=resources, **kw)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 199, in from_file
return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/notebook.py", line 32, in from_notebook_node
nb_copy, resources = super().from_notebook_node(nb, resources, **kw)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 143, in from_notebook_node
nb_copy, resources = self._preprocess(nb_copy, resources)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/exporters/exporter.py", line 318, in _preprocess
nbc, resc = preprocessor(nbc, resc)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
return self.preprocess(nb, resources)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/preprocessors/execute.py", line 79, in preprocess
self.execute()
File "/opt/conda/lib/python3.8/site-packages/nbclient/util.py", line 74, in wrapped
return just_run(coro(*args, **kwargs))
File "/opt/conda/lib/python3.8/site-packages/nbclient/util.py", line 53, in just_run
return loop.run_until_complete(coro)
File "/opt/conda/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/opt/conda/lib/python3.8/site-packages/nbclient/client.py", line 553, in async_execute
await self.async_execute_cell(
File "/opt/conda/lib/python3.8/site-packages/nbconvert/preprocessors/execute.py", line 123, in async_execute_cell
cell, resources = self.preprocess_cell(cell, self.resources, cell_index)
File "/opt/conda/lib/python3.8/site-packages/nbconvert/preprocessors/execute.py", line 146, in preprocess_cell
cell = run_sync(NotebookClient.async_execute_cell)(self, cell, index, store_history=self.store_history)
File "/opt/conda/lib/python3.8/site-packages/nbclient/util.py", line 74, in wrapped
return just_run(coro(*args, **kwargs))
File "/opt/conda/lib/python3.8/site-packages/nbclient/util.py", line 53, in just_run
return loop.run_until_complete(coro)
File "/opt/conda/lib/python3.8/site-packages/nest_asyncio.py", line 98, in run_until_complete
return f.result()
File "/opt/conda/lib/python3.8/asyncio/futures.py", line 178, in result
raise self._exception
File "/opt/conda/lib/python3.8/asyncio/tasks.py", line 280, in __step
result = coro.send(None)
File "/opt/conda/lib/python3.8/site-packages/nbclient/client.py", line 852, in async_execute_cell
self._check_raise_for_error(cell, exec_reply)
File "/opt/conda/lib/python3.8/site-packages/nbclient/client.py", line 760, in _check_raise_for_error
raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content)
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
------------------
df[['intersection_pos_rel_centre']]
from sklearn.preprocessing import LabelEncoder
le=LabelEncoder()
df[['intersection_pos_rel_centre']]=le.fit_transform(df[['intersection_pos_rel_centre']])
df[['intersection_pos_rel_centre']]
------------------
TypeError: argument must be a string or number
Here are my package versions,
$ pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.7.4 (default, Aug 14 2019, 12:09:51)
[GCC 8.3.0]
When I run
pylint {package_name}
I get a RuntimeError as shown below:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/astroid/protocols.py", line 492, in _infer_context_manager
enter = next(inferred.igetattr("__enter__", context=context))
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 10, in <module>
sys.exit(run_pylint())
File "/usr/local/lib/python3.7/site-packages/pylint/__init__.py", line 20, in run_pylint
Run(sys.argv[1:])
File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 1628, in __init__
linter.check(args)
File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 943, in check
self._do_check(files_or_modules)
File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 1075, in _do_check
self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
File "/usr/local/lib/python3.7/site-packages/pylint/lint.py", line 1158, in check_astroid_module
walker.walk(ast_node)
File "/usr/local/lib/python3.7/site-packages/pylint/utils.py", line 1303, in walk
self.walk(child)
File "/usr/local/lib/python3.7/site-packages/pylint/utils.py", line 1300, in walk
cb(astroid)
File "/usr/local/lib/python3.7/site-packages/pylint/checkers/variables.py", line 1590, in visit_import
module = next(_infer_name_module(node, parts[0]))
File "/usr/local/lib/python3.7/site-packages/astroid/util.py", line 160, in limit_inference
yield from islice(iterator, size)
File "/usr/local/lib/python3.7/site-packages/astroid/context.py", line 113, in cache_generator
for result in generator:
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
yield next(generator)
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
res = next(generator)
File "/usr/local/lib/python3.7/site-packages/astroid/inference.py", line 240, in infer_import
yield self.do_import_module(name)
File "/usr/local/lib/python3.7/site-packages/astroid/mixins.py", line 100, in do_import_module
modname, level=level, relative_only=level and level >= 1
File "/usr/local/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 619, in import_module
return MANAGER.ast_from_module_name(absmodname)
File "/usr/local/lib/python3.7/site-packages/astroid/manager.py", line 171, in ast_from_module_name
return self.ast_from_file(found_spec.location, modname, fallback=False)
File "/usr/local/lib/python3.7/site-packages/astroid/manager.py", line 91, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "/usr/local/lib/python3.7/site-packages/astroid/builder.py", line 136, in file_build
return self._post_build(module, encoding)
File "/usr/local/lib/python3.7/site-packages/astroid/builder.py", line 153, in _post_build
self.add_from_names_to_locals(from_node)
File "/usr/local/lib/python3.7/site-packages/astroid/builder.py", line 206, in add_from_names_to_locals
imported = node.do_import_module()
File "/usr/local/lib/python3.7/site-packages/astroid/mixins.py", line 100, in do_import_module
modname, level=level, relative_only=level and level >= 1
File "/usr/local/lib/python3.7/site-packages/astroid/scoped_nodes.py", line 619, in import_module
return MANAGER.ast_from_module_name(absmodname)
File "/usr/local/lib/python3.7/site-packages/astroid/manager.py", line 171, in ast_from_module_name
return self.ast_from_file(found_spec.location, modname, fallback=False)
File "/usr/local/lib/python3.7/site-packages/astroid/manager.py", line 91, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "/usr/local/lib/python3.7/site-packages/astroid/builder.py", line 136, in file_build
return self._post_build(module, encoding)
File "/usr/local/lib/python3.7/site-packages/astroid/builder.py", line 156, in _post_build
self.delayed_assattr(delayed)
File "/usr/local/lib/python3.7/site-packages/astroid/builder.py", line 223, in delayed_assattr
for inferred in node.expr.infer():
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 141, in raise_if_nothing_inferred
yield from generator
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
res = next(generator)
File "/usr/local/lib/python3.7/site-packages/astroid/inference.py", line 279, in infer_attribute
for owner in self.expr.infer(context):
File "/usr/local/lib/python3.7/site-packages/astroid/util.py", line 160, in limit_inference
yield from islice(iterator, size)
File "/usr/local/lib/python3.7/site-packages/astroid/context.py", line 113, in cache_generator
for result in generator:
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 141, in raise_if_nothing_inferred
yield from generator
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 95, in wrapped
res = next(generator)
File "/usr/local/lib/python3.7/site-packages/astroid/bases.py", line 137, in _infer_stmts
for inferred in stmt.infer(context=context):
File "/usr/local/lib/python3.7/site-packages/astroid/util.py", line 160, in limit_inference
yield from islice(iterator, size)
File "/usr/local/lib/python3.7/site-packages/astroid/context.py", line 113, in cache_generator
for result in generator:
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
yield next(generator)
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 92, in wrapped
generator = _func(node, context, **kwargs)
File "/usr/local/lib/python3.7/site-packages/astroid/inference.py", line 832, in infer_assign
stmts = list(self.assigned_stmts(context=context))
File "/usr/local/lib/python3.7/site-packages/astroid/decorators.py", line 131, in raise_if_nothing_inferred
yield next(generator)
File "/usr/local/lib/python3.7/site-packages/astroid/protocols.py", line 537, in with_assigned_stmts
yield from _infer_context_manager(self, mgr, context)
RuntimeError: generator raised StopIteration
From some search, it seems like this error should've been fixed with Pylint 2.x, however, I still get an error with the latest versions with Python 3.7. Any fixes?
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)]))
Facing the following error in a Pyramid Application while using SQLAlchemy and Zope Transaction Manager.
This is how I am creating a scoped session:
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.schema import MetaData
from sqlalchemy.orm import (
scoped_session,
sessionmaker,
)
from zope.sqlalchemy import ZopeTransactionExtension
metadata = MetaData(naming_convention=NAMING_CONVENTION)
Base = declarative_base(metadata=metadata)
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension(keep_session=True)))
I am syncing my session creation and removal with my requests in the following way:
#view_config(route_name='social_get_individual_assets', renderer='json', effective_principals=2, permission='edit')
def social_get_individual_assets(requestJson):
session = DBSession()
try:
body = requestJson.request.json_body
search_term = body['text']
horizontal = body['horizontal']
vertical = body['vertical']
log.info("social get individual assets request: %s", str(search_term).encode(encoding='utf_8'))
json_data = get_individual_assets(session, search_term, horizontal, vertical)
log.info("social get assets response: %s", str(search_term).encode(encoding='utf_8'))
transaction.commit()
DBSession.remove()
return json_data
except Exception as e:
session.rollback()
log.exception(e)
raise e
For some reason, I keep running into this error all the time:
2017-12-06 13:32:07,965 ERROR [invideoapp.views.default:465] An operation previously failed, with traceback:
File "/usr/lib64/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib64/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/site-packages/waitress/task.py", line 78, in handler_thread
task.service()
File "/usr/local/lib/python3.5/site-packages/waitress/channel.py", line 338, in service
task.service()
File "/usr/local/lib/python3.5/site-packages/waitress/task.py", line 169, in service
self.execute()
File "/usr/local/lib/python3.5/site-packages/waitress/task.py", line 399, in execute
app_iter = self.channel.server.application(env, start_response)
File "/usr/local/lib/python3.5/site-packages/pyramid/router.py", line 270, in __call__
response = self.execution_policy(environ, self)
File "/usr/local/lib/python3.5/site-packages/pyramid_retry/__init__.py", line 114, in retry_policy
response = router.invoke_request(request)
File "/usr/local/lib/python3.5/site-packages/pyramid/router.py", line 249, in invoke_request
response = handle_request(request)
File "/usr/local/lib/python3.5/site-packages/pyramid_tm/__init__.py", line 136, in tm_tween
response = handler(request)
File "/usr/local/lib/python3.5/site-packages/pyramid/tweens.py", line 39, in excview_tween
response = handler(request)
File "/usr/local/lib/python3.5/site-packages/pyramid/router.py", line 156, in handle_request
view_name
File "/usr/local/lib/python3.5/site-packages/pyramid/view.py", line 642, in _call_view
response = view_callable(context, request)
File "/usr/local/lib/python3.5/site-packages/pyramid/viewderivers.py", line 439, in rendered_view
result = view(context, request)
File "/usr/local/lib/python3.5/site-packages/pyramid/viewderivers.py", line 148, in _requestonly_view
response = view(request)
File "/home/ttv/invideoapp/invideoapp/views/default.py", line 148, in upload_image
transaction.commit()
File "/usr/local/lib/python3.5/site-packages/transaction/_manager.py", line 131, in commit
return self.get().commit()
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 308, in commit
t, v, tb = self._saveAndGetCommitishError()
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 301, in commit
self._commitResources()
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 446, in _commitResources
reraise(t, v, tb)
File "/usr/local/lib/python3.5/site-packages/transaction/_compat.py", line 54, in reraise
raise value
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 423, in _commitResources
rm.tpc_vote(self)
File "/usr/local/lib/python3.5/site-packages/zope/sqlalchemy/datamanager.py", line 109, in tpc_vote
self.tx.commit()
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 459, in commit
self._assert_active(prepared_ok=True)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 285, in _assert_active
raise sa_exc.ResourceClosedError(closed_msg)
sqlalchemy.exc.ResourceClosedError: This transaction is closed
Traceback (most recent call last):
File "/home/ttv/invideoapp/invideoapp/views/default.py", line 451, in update_master_json
user = getUser(session,user_id)
File "/home/ttv/invideoapp/invideoapp/invideomodules/auth_processing.py", line 12, in getUser
raise e
File "/home/ttv/invideoapp/invideoapp/invideomodules/auth_processing.py", line 8, in getUser
query = session.query(User).filter(User.user_id == userid).first()
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/query.py", line 2755, in first
ret = list(self[0:1])
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/query.py", line 2547, in __getitem__
return list(res)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/query.py", line 2855, in __iter__
return self._execute_and_instances(context)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/query.py", line 2876, in _execute_and_instances
close_with_result=True)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/query.py", line 2885, in _get_bind_args
**kw
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/query.py", line 2867, in _connection_from_session
conn = self.session.connection(**kw)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 966, in connection
execution_options=execution_options)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 971, in _connection_for_bind
engine, execution_options)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 417, in _connection_for_bind
self.session.dispatch.after_begin(self.session, self, conn)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/event/attr.py", line 256, in __call__
fn(*args, **kw)
File "/usr/local/lib/python3.5/site-packages/zope/sqlalchemy/datamanager.py", line 237, in after_begin
join_transaction(session, self.initial_state, self.transaction_manager, self.keep_session)
File "/usr/local/lib/python3.5/site-packages/zope/sqlalchemy/datamanager.py", line 211, in join_transaction
DataManager(session, initial_state, transaction_manager, keep_session=keep_session)
File "/usr/local/lib/python3.5/site-packages/zope/sqlalchemy/datamanager.py", line 73, in __init__
transaction_manager.get().join(self)
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 179, in join
self._prior_operation_failed() # doesn't return
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 173, in _prior_operation_failed
self._failure_traceback.getvalue())
transaction.interfaces.TransactionFailedError: An operation previously failed, with traceback:
File "/usr/lib64/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib64/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/site-packages/waitress/task.py", line 78, in handler_thread
task.service()
File "/usr/local/lib/python3.5/site-packages/waitress/channel.py", line 338, in service
task.service()
File "/usr/local/lib/python3.5/site-packages/waitress/task.py", line 169, in service
self.execute()
File "/usr/local/lib/python3.5/site-packages/waitress/task.py", line 399, in execute
app_iter = self.channel.server.application(env, start_response)
File "/usr/local/lib/python3.5/site-packages/pyramid/router.py", line 270, in __call__
response = self.execution_policy(environ, self)
File "/usr/local/lib/python3.5/site-packages/pyramid_retry/__init__.py", line 114, in retry_policy
response = router.invoke_request(request)
File "/usr/local/lib/python3.5/site-packages/pyramid/router.py", line 249, in invoke_request
response = handle_request(request)
File "/usr/local/lib/python3.5/site-packages/pyramid_tm/__init__.py", line 136, in tm_tween
response = handler(request)
File "/usr/local/lib/python3.5/site-packages/pyramid/tweens.py", line 39, in excview_tween
response = handler(request)
File "/usr/local/lib/python3.5/site-packages/pyramid/router.py", line 156, in handle_request
view_name
File "/usr/local/lib/python3.5/site-packages/pyramid/view.py", line 642, in _call_view
response = view_callable(context, request)
File "/usr/local/lib/python3.5/site-packages/pyramid/viewderivers.py", line 439, in rendered_view
result = view(context, request)
File "/usr/local/lib/python3.5/site-packages/pyramid/viewderivers.py", line 148, in _requestonly_view
response = view(request)
File "/home/ttv/invideoapp/invideoapp/views/default.py", line 148, in upload_image
transaction.commit()
File "/usr/local/lib/python3.5/site-packages/transaction/_manager.py", line 131, in commit
return self.get().commit()
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 308, in commit
t, v, tb = self._saveAndGetCommitishError()
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 301, in commit
self._commitResources()
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 446, in _commitResources
reraise(t, v, tb)
File "/usr/local/lib/python3.5/site-packages/transaction/_compat.py", line 54, in reraise
raise value
File "/usr/local/lib/python3.5/site-packages/transaction/_transaction.py", line 423, in _commitResources
rm.tpc_vote(self)
File "/usr/local/lib/python3.5/site-packages/zope/sqlalchemy/datamanager.py", line 109, in tpc_vote
self.tx.commit()
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 459, in commit
self._assert_active(prepared_ok=True)
File "/usr/local/lib64/python3.5/site-packages/sqlalchemy/orm/session.py", line 285, in _assert_active
raise sa_exc.ResourceClosedError(closed_msg)
sqlalchemy.exc.ResourceClosedError: This transaction is closed
Once I get this error, none of my Database connection stuff works. Only way out is to restart the entire application to make things work. Any idea why this is happening?
I had a similar problem, and I found using DBSession.begin_nested() solved the issue. So something like:
#view_config(route_name='social_get_individual_assets', renderer='json', effective_principals=2, permission='edit')
def social_get_individual_assets(requestJson):
try:
DBSession.begin_nested()
body = requestJson.request.json_body
search_term = body['text']
horizontal = body['horizontal']
vertical = body['vertical']
log.info("social get individual assets request: %s", str(search_term).encode(encoding='utf_8'))
json_data = get_individual_assets(session, search_term, horizontal, vertical)
log.info("social get assets response: %s", str(search_term).encode(encoding='utf_8'))
return json_data
except Exception as e:
DBSession.rollback()
log.exception(e)
raise e
I'm getting a "TemplateSyntaxError: Could not parse the remainder:" here: https://docs.djangoproject.com/en/1.7/intro/tutorial05/
>>> response = client.get(reverse('polls:index'))
gets me this:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Library/Python/2.7/site-packages/django/test/client.py", line 470, in get
**extra)
File "/Library/Python/2.7/site-packages/django/test/client.py", line 286, in get
return self.generic('GET', path, secure=secure, **r)
File "/Library/Python/2.7/site-packages/django/test/client.py", line 358, in generic
return self.request(**r)
File "/Library/Python/2.7/site-packages/django/test/client.py", line 440, in request
six.reraise(*exc_info)
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 137, in get_response
response = response.render()
File "/Library/Python/2.7/site-packages/django/template/response.py", line 103, in render
self.content = self.rendered_content
File "/Library/Python/2.7/site-packages/django/template/response.py", line 78, in rendered_content
template = self.resolve_template(self.template_name)
File "/Library/Python/2.7/site-packages/django/template/response.py", line 54, in resolve_template
return loader.select_template(template)
File "/Library/Python/2.7/site-packages/django/template/loader.py", line 188, in select_template
return get_template(template_name, dirs)
File "/Library/Python/2.7/site-packages/django/template/loader.py", line 144, in get_template
template, origin = find_template(template_name, dirs)
File "/Library/Python/2.7/site-packages/django/template/loader.py", line 132, in find_template
source, display_name = loader(name, dirs)
File "/Library/Python/2.7/site-packages/django/template/loader.py", line 44, in __call__
return self.load_template(template_name, template_dirs)
File "/Library/Python/2.7/site-packages/django/template/loader.py", line 50, in load_template
template = get_template_from_string(source, origin, template_name)
File "/Library/Python/2.7/site-packages/django/template/loader.py", line 156, in get_template_from_string
return Template(source, origin, name)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 132, in __init__
self.nodelist = compile_string(template_string, origin)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 162, in compile_string
return parser.parse()
File "/Library/Python/2.7/site-packages/django/template/base.py", line 290, in parse
compiled_result = compile_func(self, token)
File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 975, in do_if
nodelist = parser.parse(('elif', 'else', 'endif'))
File "/Library/Python/2.7/site-packages/django/template/base.py", line 290, in parse
compiled_result = compile_func(self, token)
File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 833, in do_for
nodelist_loop = parser.parse(('empty', 'endfor',))
File "/Library/Python/2.7/site-packages/django/template/base.py", line 290, in parse
compiled_result = compile_func(self, token)
File "/Library/Python/2.7/site-packages/django/template/defaulttags.py", line 1345, in url
viewname = parser.compile_filter(bits[1])
File "/Library/Python/2.7/site-packages/django/template/base.py", line 372, in compile_filter
return FilterExpression(token, self)
File "/Library/Python/2.7/site-packages/django/template/base.py", line 588, in __init__
"from '%s'" % (token[upto:], token))
TemplateSyntaxError: Could not parse the remainder: '\u2018polls:detail\u2019' from '\u2018polls:detail\u2019'
How to resolve this ?
You are using left quote and right quote characters when quoting the view name; where you should be using single or double quotes.
Use either 'polls:details' or "polls:details"