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

Support defining global env vars in a config and using complex aliases. #46

Merged
merged 1 commit into from
May 17, 2023

Conversation

MHendricks
Copy link
Member

To replicate the bug, add this environment section to tests/configs/app/app_aliased_mod.json

    "environment": {
        "set" : {
            "CONFIG_DEFINED": "config_variable"
        }
    }

Then when running this hab command, an KeyError: 'environment' error is raised.

$ hab -v dump app/aliased/mod
INFO:hab.cli:Context: app/aliased/mod
INFO:hab.solvers:Resolving requirements: {'aliased': <Requirement('aliased')>, 'aliased_mod': <Requirement('aliased_mod')>}
INFO:hab.solvers:Attempt 1 at resolving requirements
Hab encountered an error:
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\blur\dev\hab_\hab\__main__.py", line 14, in <module>
    sys.exit(hab.cli.cli(prog_name="python -m hab"))
  File "C:\blur\dev\hab_\hab\cli.py", line 496, in cli
    return _cli(*args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Python39\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Python39\lib\site-packages\click\decorators.py", line 38, in new_func
    return f(get_current_context().obj, *args, **kwargs)
  File "C:\blur\dev\hab_\hab\cli.py", line 415, in dump
    ret = settings.resolver.resolve(uri)
  File "C:\blur\dev\hab_\hab\__init__.py", line 270, in resolve
    return context.reduced(self, uri=uri)
  File "C:\blur\dev\hab_\hab\parsers\hab_base.py", line 489, in reduced
    return FlatConfig(self, resolver, uri=uri)
  File "C:\blur\dev\hab_\hab\parsers\flat_config.py", line 28, in __init__
    self._finalize_values()
  File "C:\blur\dev\hab_\hab\parsers\flat_config.py", line 71, in _finalize_values
    for platform, alias, data in self._process_version(
  File "C:\blur\dev\hab_\hab\parsers\flat_config.py", line 132, in _process_version
    global_env = self.frozen_data["environment"].get(host_platform, {})
KeyError: 'environment'

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

This MR forces the population of frozen_data["environment"] at the correct time so it can be when processing complex aliases.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Reviewed

@MHendricks MHendricks merged commit ad77a53 into blurstudio:main May 17, 2023
@MHendricks MHendricks deleted the env_key_fix branch May 17, 2023 22:35
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