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

ImageConfig should contain the image from sandbox.config #1106

Merged
merged 4 commits into from
Jul 29, 2022
Merged

Conversation

pingsutw
Copy link
Member

Signed-off-by: Kevin Su [email protected]

TL;DR

Failed to run this example because ImageConfig doesn't contain the image from sandbox.config

(flytekit-3.9) ➜  core git:(master) ✗ pyflyte --config sandbox.config run --remote containerization/multi_images.py my_workflow
Traceback (most recent call last):
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/bin/pyflyte", line 33, in <module>
    sys.exit(load_entry_point('flytekit', 'console_scripts', 'pyflyte')())
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/kevin/opt/anaconda3/envs/flytekit-3.9/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/kevin/git/flytekit/flytekit/clis/sdk_in_container/run.py", line 519, in _run
    remote_entity = remote.register_script(
  File "/Users/kevin/git/flytekit/flytekit/remote/remote.py", line 625, in register_script
    return self.register_workflow(entity, serialization_settings, version, default_launch_plan, options)
  File "/Users/kevin/git/flytekit/flytekit/remote/remote.py", line 499, in register_workflow
    ident = self._serialize_and_register(entity, serialization_settings, version, options)
  File "/Users/kevin/git/flytekit/flytekit/remote/remote.py", line 391, in _serialize_and_register
    _ = get_serializable(m, settings=serialization_settings, entity=entity, options=options)
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 581, in get_serializable
    cp_entity = get_serializable_workflow(entity_mapping, settings, entity, options)
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 226, in get_serializable_workflow
    upstream_node_models = [
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 227, in <listcomp>
    get_serializable(entity_mapping, settings, n, options)
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 584, in get_serializable
    cp_entity = get_serializable_node(entity_mapping, settings, entity, options)
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 412, in get_serializable_node
    task_spec = get_serializable(entity_mapping, settings, entity.flyte_entity, options=options)
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 578, in get_serializable
    cp_entity = get_serializable_task(entity_mapping, settings, entity)
  File "/Users/kevin/git/flytekit/flytekit/tools/translator.py", line 173, in get_serializable_task
    container = entity.get_container(settings)
  File "/Users/kevin/git/flytekit/flytekit/core/python_auto_container.py", line 164, in get_container
    image=get_registerable_container_image(self.container_image, settings.image_config),
  File "/Users/kevin/git/flytekit/flytekit/core/python_auto_container.py", line 235, in get_registerable_container_image
    raise AssertionError(f"Image Config with name {name} not found in the configuration")
AssertionError: Image Config with name trainer not found in the configuration

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

https://github.com/flyteorg/flyte/issues/

Follow-up issue

NA
OR
https://github.com/flyteorg/flyte/issues/

@codecov
Copy link

codecov bot commented Jul 20, 2022

Codecov Report

Merging #1106 (6e9b3a3) into master (72705a1) will decrease coverage by 18.54%.
The diff coverage is 63.63%.

@@             Coverage Diff             @@
##           master    #1106       +/-   ##
===========================================
- Coverage   86.67%   68.13%   -18.55%     
===========================================
  Files         269      287       +18     
  Lines       25074    25762      +688     
  Branches     2826     2882       +56     
===========================================
- Hits        21734    17553     -4181     
- Misses       2871     7733     +4862     
- Partials      469      476        +7     
Impacted Files Coverage Δ
flytekit/clis/sdk_in_container/run.py 76.84% <14.28%> (-3.09%) ⬇️
flytekit/configuration/__init__.py 36.05% <66.66%> (-58.92%) ⬇️
flytekit/configuration/internal.py 16.00% <76.92%> (-79.84%) ⬇️
...s/flytekit/unit/configuration/test_image_config.py 100.00% <100.00%> (ø)
tests/flytekit/unit/configuration/test_internal.py 100.00% <100.00%> (ø)
...ests/flytekit/unit/configuration/test_yaml_file.py 100.00% <100.00%> (ø)
flytekit/deck/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
flytekit/core/constants.py 0.00% <0.00%> (-100.00%) ⬇️
flytekit/core/resources.py 0.00% <0.00%> (-100.00%) ⬇️
flytekit/core/tracked_abc.py 0.00% <0.00%> (-100.00%) ⬇️
... and 130 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72705a1...6e9b3a3. Read the comment docs.

Copy link
Collaborator

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

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

This is not quite right yet. IIUC, this PR makes it so that the --config flag (which applies at the top level) becomes a required parameter.

Also, the images config section has no equivalent in the yaml config, right?

pingsutw added 2 commits July 26, 2022 22:48
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
@pingsutw
Copy link
Member Author

sorry, updated it.

  • Now --config flag should be optional.
  • Support reading image config in yaml config

eapolinario
eapolinario previously approved these changes Jul 27, 2022
Copy link
Collaborator

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

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

LGTM.

@@ -512,12 +512,19 @@ def _run(*args, **kwargs):
return

remote = ctx.obj[FLYTE_REMOTE_INSTANCE_KEY]
config_file = ctx.obj.get(CTX_CONFIG_FILE)
Copy link
Collaborator

@eapolinario eapolinario Jul 27, 2022

Choose a reason for hiding this comment

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

just for own understanding, what's the level that config is applied? As in, can you pass the --config flag to the run subcommand (e.g. pyflyte run --config <file.yaml> --remote ...)? Or it has to come before the run subcommand?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still have to use --config before the run. like pyflyte --config flyte.yaml run ....

@pingsutw pingsutw marked this pull request as draft July 27, 2022 13:42
@pingsutw
Copy link
Member Author

Convert it to draft, need further discussion with Yee

@@ -11,3 +11,6 @@ storage:
access-key: minio
endpoint: http://localhost:30084
secret-key: miniostorage
images:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is supported at all on the flytectl side (and might never be since it's mostly responsible for registration time settings) but that's ok. We can still support this.

@@ -512,12 +512,19 @@ def _run(*args, **kwargs):
return

remote = ctx.obj[FLYTE_REMOTE_INSTANCE_KEY]
config_file = ctx.obj.get(CTX_CONFIG_FILE)

image_config = run_level_params.get("image_config", None)
Copy link
Contributor

Choose a reason for hiding this comment

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

so image_config is never going to be None because of the default and because of the validate_image callback. So the ImageConfig.auto will never be called.

if image_config:
image_config.images.extend(ImageConfig.auto(config_file).images)
else:
image_config = ImageConfig.auto(config_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is called actually, this will fail if config_file is None because ImageConfig.auto(config_file=None) will return a

    for k, v in _internal.Images.get_specified_images(config_file).items()
E   AttributeError: 'NoneType' object has no attribute 'items'

error

flytekit/configuration/__init__.py Show resolved Hide resolved
images[str(i)] = cfg.legacy_config.get("images", i)
return images
if cfg.yaml_config:
return cfg.yaml_config.get("images")
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to return {} in case it doesn't exist.

flytekit/configuration/__init__.py Show resolved Hide resolved

image_config = run_level_params.get("image_config", None)
if image_config:
image_config.images.extend(ImageConfig.auto(config_file).images)
Copy link
Contributor

Choose a reason for hiding this comment

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

also how does this work? weird. isn't ImageConfig supposed to be frozen??


Signed-off-by: Yee Hing Tong <[email protected]>
@pingsutw pingsutw marked this pull request as ready for review July 29, 2022 17:20
@pingsutw pingsutw merged commit 9d31342 into master Jul 29, 2022
wild-endeavor added a commit that referenced this pull request Aug 2, 2022
* ImageConfig should contain the image from sandbox.config

Signed-off-by: Kevin Su <[email protected]>

* Updated

Signed-off-by: Kevin Su <[email protected]>

* lint

Signed-off-by: Kevin Su <[email protected]>

* pr into #1106 (#1113)



Signed-off-by: Yee Hing Tong <[email protected]>

Co-authored-by: Yee Hing Tong <[email protected]>
wild-endeavor added a commit that referenced this pull request Aug 2, 2022
* ImageConfig should contain the image from sandbox.config

Signed-off-by: Kevin Su <[email protected]>

* Updated

Signed-off-by: Kevin Su <[email protected]>

* lint

Signed-off-by: Kevin Su <[email protected]>

* pr into #1106 (#1113)



Signed-off-by: Yee Hing Tong <[email protected]>

Co-authored-by: Yee Hing Tong <[email protected]>
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.

3 participants