Skip to content

feat: use new mapping - #888

Merged
ruben-arts merged 20 commits into
prefix-dev:mainfrom
nichtmacho:feat/use-new-mapping
Apr 8, 2024
Merged

ruben-arts merged 20 commits into
prefix-dev:mainfrom
nichtmacho:feat/use-new-mapping

Conversation

@nichtmacho

@nichtmacho nichtmacho commented Feb 29, 2024 •

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/pypi_name_mapping.rs Resolved
@nichtmacho
nichtmacho marked this pull request as ready for review March 7, 2024 21:24
Comment thread src/lock_file/update.rs Resolved
Comment thread src/pypi_name_mapping.rs Resolved
Comment thread src/pypi_name_mapping.rs Resolved
@baszalmstra

Copy link
Copy Markdown
Contributor

Before we merge this we want to make sure we open source the repository that generates the mapping.

@ruben-arts ruben-arts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also use the mapping in lock_file::pypi::resolve_dependencies so we don't add the wrong packages to the resolve.

Comment thread src/pypi_name_mapping.rs Resolved
@wolfv
wolfv force-pushed the feat/use-new-mapping branch from f051f66 to 5ba6042 Compare March 20, 2024 14:19
@wolfv

wolfv commented Mar 20, 2024

Copy link
Copy Markdown
Member

I just rebased this PR on main.

A few things I am wondering:

  • should we even retry fetching the mapping? I think in some corporate environments this will be blocked etc, so retrying will be futile :)
  • we just discussed via voice that we do not store a mapping if the conda package has no corresponding pypi package. In that case it seems like we'd be retrying 3 times now for a file that doesn't exist. That sounds slow.

I think we might be better off not retrying and it might also be good to have some graceful fallback - maybe with the current github file, or something hard-coded?

@nichtmacho

Copy link
Copy Markdown
Contributor Author

I just rebased this PR on main.

A few things I am wondering:

  • should we even retry fetching the mapping? I think in some corporate environments this will be blocked etc, so retrying will be futile :)
  • we just discussed via voice that we do not store a mapping if the conda package has no corresponding pypi package. In that case it seems like we'd be retrying 3 times now for a file that doesn't exist. That sounds slow.

I think we might be better off not retrying and it might also be good to have some graceful fallback - maybe with the current github file, or something hard-coded?

What do you mean by hard-coded/current github file?

@baszalmstra

Copy link
Copy Markdown
Contributor

Retry with the middleware only happens for 500 errors and same rare 42x cases. A missing entry will not be retried.

I assume corporate firewalls will also return a normal 40x status which will also not be retried.

The main usecase for retry is to retry server issues.

@baszalmstra

Copy link
Copy Markdown
Contributor

@wolfv

wolfv commented Mar 20, 2024

Copy link
Copy Markdown
Member

Ah great, good to know!

@ruben-arts

Copy link
Copy Markdown
Contributor

Could you also add documentation on the use and working of this mapping?

Comment thread src/project/manifest/mod.rs Resolved
Comment thread src/project/mod.rs Resolved
Comment thread src/project/manifest/metadata.rs Outdated
pub documentation: Option<Url>,

/// URL of the pypi name mapping
pub pypi_name_mapping: Option<Url>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im thinking that maybe we should have a mapping per channel. So you can use the prefix one for conda-forge but use a custom mapping for your own private channel?

WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea!
some small discovery questions about how do you see it:

  • do we want to also allow to override conda-forge with your own mapping?
  • do we want to expose configuration via pypi-name-mapping = {"conda-forge": ..my_path, "my-own-channel": ..my_another_path } , or to hide the channel in the mapping itself? ( I go with the first approach )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to also allow to override conda-forge with your own mapping?

When we have mirrors or you are behind a firewall, then yes.

do we want to expose configuration via pypi-name-mapping = {"conda-forge": ..my_path, "my-own-channel": ..my_another_path } , or to hide the channel in the mapping itself? ( I go with the first approach )

@ruben-arts @wolfv WDYT?

@ruben-arts ruben-arts Apr 3, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this!

Edit: Scrap the seperate table idea, this is a standalone definition specific to the project. So this is good.

[project]
pypi-name-mapping = { conda-forge = "url", "https://prefix.dev/my_channel" = "url" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having some doubts on the name. What about:

  • conda-pypi-map
  • channel-index-map
  • conda-pypi-package-map

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about starting a [pypi-options] table? I feel there could be a number of future options to handle (keyring, extra index, etc.)

Not sure re. the specific name of the map, but we could maybe take 'pypi' out of it if it sits under a [pypi-options] table

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about starting a [pypi-options] table? I feel there could be a number of future options to handle (keyring, extra index, etc.)

Not sure re. the specific name of the map, but we could maybe take 'pypi' out of it if it sits under a [pypi-options] table

Hey @olivier-lacroix ! Good question!

My rationale for using [project] is that mapping is used for both conda and pypi - so in my view because we map conda name to python name, the upstream for it is the [project] table.
I'm totally open for any other ideas - maybe we can also ask @ruben-arts and @baszalmstra

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @nichmor, not a bad idea but not required in this case.

Comment thread docs/configuration.md Resolved
Comment thread docs/configuration.md Resolved
Comment thread docs/configuration.md Resolved
Comment thread src/project/manifest/metadata.rs Resolved
Comment thread src/pypi_mapping/custom_pypi_mapping.rs Resolved

@baszalmstra baszalmstra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me except that if I read it correctly you are only using the prefix mapping by default for packages from conda-forge. However, you can use the prefix mapping for all packages!

Comment thread src/project/manifest/mod.rs Resolved
Comment thread src/pypi_mapping/custom_pypi_mapping.rs Resolved
@baszalmstra

Copy link
Copy Markdown
Contributor

I approve of this PR! @ruben-arts If you are happy with it, feel free to merge :)

Comment thread src/pypi_mapping/custom_pypi_mapping.rs Outdated
Comment on lines +27 to +32
let response = client
.get(url.clone())
.send()
.await
.into_diagnostic()
.context("failed to download pypi mapping from custom location")?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested what happens if you give a broken URL but then this doesn't get shown but then next one does. Could you make sure that it fails on downloading, and that it adds atleast also adds the url to the error so it helps the user find the cultprit? Now it gives this error:

  × failed to parse pypi name mapping
  ├─▶ error decoding response body: invalid type: integer `404`, expected a map at line 1 column 3
  ╰─▶ invalid type: integer `404`, expected a map at line 1 column 3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-04-08 at 14 56 24 change the logic so know it will throw following error if requested mapping could not be located

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and following error if json is bad formatted ( for example, could not be able to serialized in our struct )
Screenshot 2024-04-08 at 14 58 36

Comment thread src/project/manifest/mod.rs Outdated
})
.collect::<miette::Result<HashMap<ChannelName, MappingLocation>>>()?;

Ok(MappingSource::Custom { mapping })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to also warn the user if the have a mapping to conda-flibediefloep that it tells them that that channel doesn't exist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-04-08 at 14 49 51 Changed the logic a little so know it will print a warning if defined channel is not present in project.channels

Comment thread src/pypi_mapping/custom_pypi_mapping.rs Resolved
Comment thread tests/test_examples.sh Resolved

@ruben-arts ruben-arts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants