There are two methods to implement for a dependency provider:
choose_package_version
get_dependencies
Those are the only parts of the solver potentially doing IO. We want to minimize the amount of network calls and file system read.
Connectivity modes
offline: use exclusively installed packages.
online: no network restriction to select packages.
~prioritized: no restriction, but installed packages are prioritized~.
progressive (default): try offline first, if it fails switch to ~prioritized~ online.
offline
We use the OfflineDependencyProvider as a base for this.
For choose_package_version, we can only pick versions existing on the file system. In addition, we only want to query the file system once per package needed. So, the first time we want the list of versions for a given package, we walk the cache of installed versions in ~/.elm/0.19.1/packages/author/package/and register in an OfflineDependencyProvider those packages. Then we can call offline_provider.choose_package_version(...).
For get_dependencies, we can directly call offline_provider.get_dependencies() since we have already registered packages with their dependencies when walking the cache of installed versions in choose_package_version.
Rmq: this can be slightly more efficient if instead of OfflineDependencyProvider, we make our own, in which we store existing packages and dependencies in two different fields, to avoid the need of deserializing the elm.json of all versions when we just want the existing version numbers, known with the existing directories.
online
At the beginning we make one call to https://package.elm-lang.org/packages/since/... to update our list of existing packages.
For choose_package_version, we simply use the pubgrub helper function: choose_package_with_fewest_versions.
For get_dependencies, we check if those have been cached already, otherwise we check if the package is installed on the disk and read there, otherwise we ask for dependencies on the network.
~prioritized~
At the beginning we update the list of existing packages just like in online mode.
For choose_package_version, we can prioritize installed packages. A concrete way of doing it is using the choose_package_with_fewest_versions strategy with a function that list only installed versions first, followed by all other versions.
For get_dependencies, we do the same that in online mode.
progressive (default)
Try to resolve dependencies in offline mode. If it fails, repeat in ~prioritized~ online mode.
There are two methods to implement for a dependency provider:
choose_package_version
get_dependencies
Those are the only parts of the solver potentially doing IO. We want to minimize the amount of network calls and file system read.
Connectivity modes
offline
We use the
OfflineDependencyProvider
as a base for this.For
choose_package_version
, we can only pick versions existing on the file system. In addition, we only want to query the file system once per package needed. So, the first time we want the list of versions for a given package, we walk the cache of installed versions in~/.elm/0.19.1/packages/author/package/
and register in anOfflineDependencyProvider
those packages. Then we can calloffline_provider.choose_package_version(...)
.For
get_dependencies
, we can directly calloffline_provider.get_dependencies()
since we have already registered packages with their dependencies when walking the cache of installed versions inchoose_package_version
.Rmq: this can be slightly more efficient if instead of
OfflineDependencyProvider
, we make our own, in which we store existing packages and dependencies in two different fields, to avoid the need of deserializing theelm.json
of all versions when we just want the existing version numbers, known with the existing directories.online
At the beginning we make one call to
https://package.elm-lang.org/packages/since/...
to update our list of existing packages.For
choose_package_version
, we simply use the pubgrub helper function:choose_package_with_fewest_versions
.For
get_dependencies
, we check if those have been cached already, otherwise we check if the package is installed on the disk and read there, otherwise we ask for dependencies on the network.~prioritized~
At the beginning we update the list of existing packages just like in online mode.
For
choose_package_version
, we can prioritize installed packages. A concrete way of doing it is using thechoose_package_with_fewest_versions
strategy with a function that list only installed versions first, followed by all other versions.For
get_dependencies
, we do the same that in online mode.progressive (default)
Try to resolve dependencies in offline mode. If it fails, repeat in ~prioritized~ online mode.