Coder Social home page Coder Social logo

Comments (8)

pawamoy avatar pawamoy commented on June 7, 2024 1

It's again because of wildcard imports (which Griffe does not handle perfectly, for various reasons).

  • (descending) freetensor wildcard imports freetensor.libop
  • which wildcard imports freetensor.libop.softmax
  • which imports freetensor.core
  • so freetensor.libop.softmax.core is an alias to freetensor.core
  • and (ascending) freetensor.libop.core is an alias to freetensor.core.softmax.core
  • and freetensor.core is an alias to freetensor.libop.core
  • thus creating an (undetected) indirect cycle freetensor.core -> freetensor.core

I think I've been able to add a guardrail against this case. I'll push a fix soon after I verified this is working properly.

from griffe.

pawamoy avatar pawamoy commented on June 7, 2024

😱

Thanks for the report, will try and replicate now 🙂

from griffe.

pawamoy avatar pawamoy commented on June 7, 2024

Griffe 0.25.1 should fix it 🙂
Let me know if it doesn't and I'll reopen.

from griffe.

roastduck avatar roastduck commented on June 7, 2024

Sorry for the late response. The infinite recursion erorr did disappear, but no API is rendered. The result is only an empty page. I have tried both Griffe 0.25.1 and 0.25.5, with other dependencies kept to the latest.

Please still use the repo mentioned in #83 to reproduce. The specific commit I tried is roastduck/FreeTensor@63cd89f .

Only the old "mkdocstrings==0.18.1" "pytkdocs[numpy-style]" works for me.

from griffe.

pawamoy avatar pawamoy commented on June 7, 2024

That's alright! Thanks for reporting :) Good to hear this is fixed. Now you're probably just missing the show_submodules: true option (globally in mkdocs.yml or locally in your Markdown page).

from griffe.

roastduck avatar roastduck commented on June 7, 2024

show_submoduels: true works, but it results in another error:

INFO     -  Building documentation...
INFO     -  mkdocstrings: DEPRECATION: mkdocstrings' watch feature is deprecated in favor of MkDocs' watch feature, see https://www.mkdocs.org/user-guide/configuration/#watch
INFO     -  Cleaning site directory
WARNING  -  griffe: freetensor/libop/element_wise.py:288: Parameter 'out' does not appear in the function signature
ERROR    -  Error building page 'api.md': Could not resolve freetensor.libop.softmax.core
Traceback (most recent call last):
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs_autorefs/plugin.py", line 78, in _get_item_url
    return self._url_map[identifier]
KeyError: 'freetensor.core.VarRef'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 945, in resolve_target
    resolved = self.modules_collection[self.target_path]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/mixins.py", line 28, in __getitem__
    return self.members[parts[0]][parts[1:]]  # type: ignore[attr-defined]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/mixins.py", line 28, in __getitem__
    return self.members[parts[0]][parts[1:]]  # type: ignore[attr-defined]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/mixins.py", line 28, in __getitem__
    return self.members[parts[0]][parts[1:]]  # type: ignore[attr-defined]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 821, in __getitem__
    return self.target[key]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/mixins.py", line 27, in __getitem__
    return self.members[parts[0]]  # type: ignore[attr-defined]
KeyError: 'core'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/rd/.local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/rd/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/rd/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/rd/.local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rd/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rd/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs/__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 82, in serve
    builder(config)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 75, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 329, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 234, in _build_page
    output = config.plugins.run_event('post_page', output, page=page, config=config)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs/plugins.py", line 517, in run_event
    result = method(item, **kwargs)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs_autorefs/plugin.py", line 205, in on_post_page
    fixed_output, unmapped = fix_refs(output, url_mapper)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs_autorefs/references.py", line 191, in fix_refs
    html = AUTO_REF_RE.sub(fix_ref(url_mapper, unmapped), html)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs_autorefs/references.py", line 157, in inner
    url = url_mapper(unescape(identifier))
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs_autorefs/plugin.py", line 107, in get_item_url
    url = self._get_item_url(identifier, fallback)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocs_autorefs/plugin.py", line 83, in _get_item_url
    new_identifiers = fallback(identifier)
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocstrings/handlers/base.py", line 508, in get_anchors
    anchors = handler.get_anchors(handler.collect(identifier, fallback_config))
  File "/home/rd/.local/lib/python3.9/site-packages/mkdocstrings_handlers/python/handler.py", line 200, in collect
    doc_object = self._modules_collection[identifier]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/mixins.py", line 28, in __getitem__
    return self.members[parts[0]][parts[1:]]  # type: ignore[attr-defined]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/mixins.py", line 28, in __getitem__
    return self.members[parts[0]][parts[1:]]  # type: ignore[attr-defined]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 821, in __getitem__
    return self.target[key]
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 921, in target
    self.resolve_target()
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 952, in resolve_target
    self._target.aliases[self.path] = self  # type: ignore[union-attr]  # we just set the target
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 812, in __getattr__
    attr = getattr(self.target, name)
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 921, in target
    self.resolve_target()
  File "/home/rd/.local/lib/python3.9/site-packages/griffe/dataclasses.py", line 947, in resolve_target
    raise AliasResolutionError(self.target_path) from error
griffe.exceptions.AliasResolutionError: Could not resolve freetensor.libop.softmax.core

freetensor.libop.softmax.core is indeed an alias. It is an from .. import core, which is actually freetensor.core. I have no idea why this alias cannot be resolved.

Tested with Griffe 0.25.5.

Feel free to open a new issue if you like.

from griffe.

pawamoy avatar pawamoy commented on June 7, 2024

One day it will work maybe 🤣

Thanks for the update, I'll investigate :)

from griffe.

pawamoy avatar pawamoy commented on June 7, 2024

Will close now, keep opening issues if you have any 🙏 ❤️

from griffe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.