Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Key "extras" does not exist.' #4665

Closed
3 tasks done
ShervinAbd92 opened this issue Oct 21, 2021 · 17 comments · Fixed by python-poetry/poetry-core#404
Closed
3 tasks done

'Key "extras" does not exist.' #4665

ShervinAbd92 opened this issue Oct 21, 2021 · 17 comments · Fixed by python-poetry/poetry-core#404
Labels
kind/bug Something isn't working as expected

Comments

@ShervinAbd92
Copy link

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Mac Catalina 10.15.7

  • Poetry version: 1.1.11

  • Link of a Gist with the contents of your pyproject.toml file:

Issue

after multiple times building & upgrading my python package, poetry gives me a following error when i run poetry install:
Installing dependencies from lock file

Package operations: 0 installs, 6 updates, 0 removals

• Updating importlib-metadata (1.7.0 -> 4.8.1)
• Updating pyrsistent (0.17.3 -> 0.18.0)
• Updating jsonschema (3.2.0 -> 4.1.2)
• Updating charset-normalizer (2.0.0 -> 2.0.7)
• Updating idna (3.1 -> 3.3)
• Updating cffi (1.14.6 -> 1.15.0)

Installing the current project: FCDproc (0.9.0)
NonExistentKey

'Key "extras" does not exist.'

at ~/opt/anaconda3/envs/fcdproc/lib/python3.7/site-packages/tomlkit/container.py:553 in getitem
549│ key = Key(key)
550│
551│ idx = self._map.get(key, None)
552│ if idx is None:
→ 553│ raise NonExistentKey(key)
554│
555│ if isinstance(idx, tuple):
556│ # The item we are getting is an out of order table
557│ # so we need a proxy to retrieve the proper objects

i am not sure why this is coming up now. any suggestion how i can fix this?

@ShervinAbd92 ShervinAbd92 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 21, 2021
@abn
Copy link
Member

abn commented Oct 27, 2021

Can you share your pyproject.toml file and the full output of poetry install -vvv?

@ShervinAbd92
Copy link
Author

ShervinAbd92 commented Oct 27, 2021 via email

@ShervinAbd92
Copy link
Author

ShervinAbd92 commented Nov 4, 2021 via email

@richardxia
Copy link

@ShervinAbd92, it doesn't look like you attached your pyproject.toml to this issue. I don't think attachments to email replies to GitHub get added to the GitHub issue.

I was running into the same issue, and I eventually figured out it was because I had a TOML key that had a period (.) in the name, which actually gets parsed as a nested property. E.g. I had something like:

[tool.poetry.scripts]
foo.bar = "myproject.main"

which ended up being parsed as something equivalent to

[tool.poetry.scripts]
foo = { bar = "myproject.main" }

Putting quotes around the key allowed me to work past the issue I was facing, so if you have something similar in your pyproject.toml, you might try adding quotes.

@ShervinAbd92
Copy link
Author

@richardxia thanks for letting me know how you were able to solve this error. i didn't realize that my attachment didn't get copied here. so i am going to show the content. however, i don't think my error is coming from the same spot, but i might be wrong.

name = "FCDproc"
version = "0.9.0"
description = "detect FCD lesions in MRI negative epilepsy patients"
authors = ["InatiLab"]
license = "GNU General Public License v3.0"
readme = "README.md"
packages = [
    { include = "./**/*.py" },
]


[tool.poetry.dependencies]
python = "~3.7"
nipype = "^1.6.1"
jem = "^0.3.12"
fmriprep = "^20.2.5"
nibabel = "^3.2.1"
nitransforms = "~=20.0.0rc3"
psutil = "^5.8.0"
pybids = "^0.13.2"
requests = "^2.26.0"
smriprep = "^0.7.2"
tedana = "~=0.0.9a1"
templateflow = "^0.7.1"
toml = "^0.10.2"
niworkflows = "^1.3"
sdcflows = "^1.3"
scikit-image = "^0.17.2"
scipy = "^1.7.1"
numpy = "^1.21.2"
pandas = {version = "^1.1.5", python = "^3.7.1" }
networks = "^0.3.7"
prov = "^2.0.0"
pydot = "^1.4.2"
python-dateutil = "^2.8.2"
rdflib = "^6.0.2"
simplejson = "^3.17.5"
traits = "^6.3.1"
filelock = "^3.3.1"
etelemetry = "^0.2.2"
packaging = "^20.4"
jupyter = "^1.0.0"
click = "^8.0.3"
globus-cli = "^3.1.2"
nipy = "^0.5.0"



[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
python-semantic-release = "^7.19.2"
myst-nb = "^0.13.1"
sphinx-autoapi = "^1.8.4"
sphinx-rtd-theme = "^1.0.0"


[tool.poetry.scripts]
FCD_Pipeline = {reference = "FCDproc.cli:Create_FCD_Pipeline", type = "console"}


[tool.semantic_release]
version_variable = "pyproject.toml:version" 
branch = "main"                             # branch to make releases of
changelog_file = "CHANGELOG.md"             # changelog file
build_command = "pip install poetry && poetry build"  # build dists
upload_to_release = true    
upload_to_pypi = false                      # don't auto-upload to PyPI
remove_dist = false  
dist_path = "dist/"                         # where to put dists                       


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

this is my directory structure:
Screen Shot 2021-11-18 at 11 14 10 AM

@ShervinAbd92
Copy link
Author

Screen Shot 2021-11-18 at 11 35 12 AM

@richardxia
Copy link

I'm just a user of Poetry, and I don't know the internals very well, but I'm curious about this line in your pyproject.toml:

[tool.poetry.scripts]
FCD_Pipeline = {reference = "FCDproc.cli:Create_FCD_Pipeline", type = "console"}

I don't see that format documented anywhere on the documentation website for Poetry. The current section on tool.poetry.scripts shows that the right-hand side of setting should just be a single string. It looks like Poetry only supports console scripts today, so there's no need to specify a type of console.

What happens if you just replace the dictionary with the string that describes the function to call?

@ShervinAbd92
Copy link
Author

@richardxia thats an interesting point. In my case FCDproc is my package name and cli.py is a script that i have defined a Create_FCD_pipeline function in it. so you i should have it like bellow?

[tools.poetry.scripts]
FCD_pipeline = { FCDproc = "cli.Create_FCD_pipeline" }

@richardxia
Copy link

No, I think it should be just the following:

[tools.poetry.scripts]
FCD_pipeline = "FCDproc.cli:Create_FCD_pipeline"

The left-hand side of the equals sign is the file name of the executable to create when installing a package, the text in the string before the colon is the package path to the module, and the text after the colon is the function to call. It's similar to the older syntax for console scripts from setuptools: https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html

@ShervinAbd92
Copy link
Author

oki sure, i can try that. thanks for your suggestion.

@mkniewallner
Copy link
Member

Hi, did you manage to make it work, to know if this issue can be closed?

@mkniewallner mkniewallner added status/waiting-on-response Waiting on response from author kind/question User questions (candidates for conversion to discussion) and removed status/triage This issue needs to be triaged kind/bug Something isn't working as expected labels Jun 11, 2022
@shubb30
Copy link

shubb30 commented Jun 23, 2022

I think am having the same issue. I am trying to get scripts #241 working in my project.
Per that issue, you need poetry==1.2.0a1 and poetry-core==1.1.0a5 which I have both.
The section in the toml I have is

[tool.poetry.scripts]
my_script = {reference = "bin/my_script.py", type = "file"}

When I run poetry check I get the errors:

  > poetry check

'extras'

If I take out the tool.poetry.scripts section, then the check succeeds.

I made a note in the other issue also, but the fix I found was to add an extras key and then it worked for me.

[tool.poetry.scripts]
my_script = {reference = "bin/my_script.py", type = "file", extras = []}

@clintonroy
Copy link
Contributor

The syntax for tool.poetry.scripts is at https://python-poetry.org/docs/pyproject/#scripts

Nothing else is supported.

@clintonroy
Copy link
Contributor

Sorry, maybe the format you're interested in is here: https://python-poetry.org/docs/master/pyproject#scripts

@TBBle
Copy link
Contributor

TBBle commented Jun 24, 2022

This issue is not fixed, python-poetry/poetry-core#404 should take care of it.

The issue is that before python-poetry/poetry-core#40, the only use of the dictionary format for scripts was to add extras, as documented at https://python-poetry.org/docs/master/pyproject#scripts (still), so it is not surprising (but was still kind-of a bug) that extras was a required key, even though it was only being enforced by accident. That was the original bug, that this ticket was opened for in Poetry 1.1:

[tool.poetry.scripts]
devtest = { callable = "mypackage:test.run_tests" }

has no reason not to be equivalent to

[tool.poetry.scripts]
my_package_cli = 'my_package.console:run'

as none of the other uses of toml inline tables in Poetry would distinguish these cases.


The Poetry docs weren't updated for python-poetry/poetry-core#40 yet, but from that change, Poetry 1.2 introduced a new use of the dictionary format for scripts, the type key, which is @shubb30's issue above. This has produced a new way to trigger the same underlying issue.

The code in poetry-core was already mostly-correct (The actual stack-trace hit in the original bug report was fixed in python-poetry/poetry-core#177), so the only missed spot appears to be Factory.validate which python-poetry/poetry-core#404 is fixing.

@mkniewallner mkniewallner reopened this Jun 24, 2022
@mkniewallner mkniewallner added kind/bug Something isn't working as expected and removed kind/question User questions (candidates for conversion to discussion) status/waiting-on-response Waiting on response from author labels Jun 25, 2022
@Susanta-Adak
Copy link

@richardxia
I encountered a recurring problem and later discovered that it was due to a TOML key that had a period (.) in its name. This caused it to be parsed as a nested property. For instance, my code had a similar structure to this:

[abc.12kx]
prop = 'val'

If you want to change any property.

data['abc']['12kx']['prop'] = 'new val'

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants