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

Add hab install to download and install required distros #112

Merged
merged 7 commits into from
Jan 24, 2025

Conversation

MHendricks
Copy link
Member

Add the cli command hab install. This resolves the required distros for multiple URI's against a remote download server, downloads and installs any missing distros.

This also re-works how distros are resolved into a DistroFinder class or subclasses. These can be used to customize how distros are resolved by hab. This includes resolving distros from aws s3 buckets.

Checklist

  • I have read the CONTRIBUTING.md document
  • I formatted my changes with black
  • I linted my changes with flake8
  • I have added documentation regarding my changes where necessary
  • Any pre-existing tests continue to pass
  • Additional tests were made covering my changes

Types of Changes

  • Bugfix (change that fixes an issue)
  • New Feature (change that adds functionality)
  • Documentation Update (if none of the other choices apply)

Proposed Changes

@MHendricks MHendricks marked this pull request as draft November 26, 2024 23:44
@MHendricks MHendricks force-pushed the mikeh/download branch 4 times, most recently from 15b5adb to 26f3146 Compare December 6, 2024 20:29
- If a object processed by `hab.utils.dump_object` has a dump method, it
will be called. Verbosity is now passed to dump_object.
- Improvements to Site.dump output including calling dump on file paths.
- `Resolver.resolve_requirements` will now call `Solver.simplify_requirements`
if passed a list automatically.
- `MergeDict.default_format` now recursively formats dictionary values.
- Documentation improvement.
Use the command `tox p` or `tox run-parallel` to enable parallel mode.
@MHendricks MHendricks force-pushed the mikeh/download branch 3 times, most recently from 988eca6 to 2aa900c Compare December 13, 2024 03:20
@MHendricks
Copy link
Member Author

I've been thinking about dropping python 3.6 for a while and some tests I'm working on are suffering from packaging.requirements not comparing equal in 3.6 which is making it so I'm likely to drop official support for it in this PR.

@MHendricks MHendricks force-pushed the mikeh/download branch 2 times, most recently from dda68f5 to cf5cb74 Compare December 17, 2024 02:27
This class will replace the current code used to find distros. This allows
us to implement sub-classes to change how they are found. For example to
allow us to resolve dependencies hosted on the cloud for download and install.

Add `hab.utils.glob_path` that supports globbing a pathlib.Path object
with glob strings in the path.
@MHendricks MHendricks force-pushed the mikeh/download branch 3 times, most recently from cb6b80b to e0c3980 Compare January 18, 2025 02:34
@MHendricks
Copy link
Member Author

I'm not dropping support for python 3.7 currently. It's still useful to be able to import hab in older applications.

However the hab install feature is not supporting using aws s3 for downloading. While it is still accessible boto3 has dropped support for it. If it stops working in the future I likely will drop support for it in python 3.7. The testing suite won't test the py37-s3 testing suite to check for issues.

These classes allow hab to resolve distros stored as .zip files both locally
and on cloud services (aws s3 buckets).
- Support sidecar .hab.json files next to the distro .zip files for remote
services that don't support reading ranges of a file.
- For services that support reading ranges of files like s3 it can download
the .hab.json file from inside of the remote .zip file without downloading
the entire .zip file first.
- Add `hab.utils.loads_json` that raises the same errors as `load_json_file`
but works on strings instead of files.
@MHendricks MHendricks force-pushed the mikeh/download branch 2 times, most recently from b7164ba to caafe56 Compare January 20, 2025 23:52
@MHendricks MHendricks marked this pull request as ready for review January 20, 2025 23:56
- Add `hab install` command that resolves all distros required to resolve
multiple URI's and then download and install any missing distros.
- Distro resolving is now handled by `DistroFinder` or sub-class.
- Site now has a downloads dictionary that configures how `hab install`
can resolve remote distros for installing locally.
- `Resolver.distro_mode_override` with context can be used to change
`Resolver.distro`'s output to the `Site.downloads["distros"] used to find
remote distros to install.
CentOS is rapidly being dropped so no longer a need to support it.
Identical pathlib requirements don't compare equal in 3.6 and below.
S3 testing features are only supported for python 3.8+
@MHendricks MHendricks merged commit ac439fd into main Jan 24, 2025
36 checks passed
@MHendricks MHendricks deleted the mikeh/download branch January 24, 2025 23:14
@MHendricks
Copy link
Member Author

I still need to update the readme but here is an example site file.

Adds the ability to resolve URI's and download and install any missing distros using a new cli command similar to pip install.
Example: hab install -u a/uri -u another/uri

The readme still needs updated but this example site file shows the basics of configuring hab install.

{
    "set": {
        "config_paths": [
            "{relative_root}/configs"
        ],
        "distro_paths": [
            "{relative_root}/distros/*"
        ],
        "downloads": {
            "cache_root": "{relative_root}/downloads",
            "distros": [
                [
                    "hab.distro_finders.s3_zip:DistroFinderS3Zip",
                    "s3://bucket-name/hab_distros",
                    {
                        "profile_name": "aws-credential-name"
                    }
                ]
            ],
            "install_root": "{relative_root}/distros"
        }
    }
}

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.

1 participant