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 ImageSpec.from_env #2895

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

thomasjpfan
Copy link
Member

Tracking issue

Closes flyteorg/flyte#5889

Why are the changes needed?

Resolve notebook environment mismatch described in flyteorg/flyte#5889

What changes were proposed in this pull request?

This PR adds a ImageSpec.from_env into ImageSpec.

How was this patch tested?

I added unit test to this PR and ran this workflow:

from pathlib import Path

from flytekit import current_context, task, workflow, ImageSpec
from flytekit.types.file import FlyteFile

image_spec = ImageSpec.from_env(
    pinned_packages=["joblib"],
    name="myimage",
    registry="localhost:30000",
    packages=[
        "git+https://github.com/thomasjpfan/flytekit@41a6a74df4bab1b7db4f9ff13eb249e94fe7a2e4"
    ],
    apt_packages=["git"],
)


@task(container_image=image_spec)
def create_file() -> FlyteFile:
    working_dir = Path(current_context().working_directory)

    file = working_dir / "outer_file.txt"
    file.write_text("this is some text")

    return file


@workflow
def main() -> FlyteFile:
    return create_file()

Signed-off-by: Thomas J. Fan <[email protected]>
Copy link

codecov bot commented Nov 23, 2024

Codecov Report

Attention: Patch coverage is 15.78947% with 16 lines in your changes missing coverage. Please review.

Project coverage is 46.62%. Comparing base (6f8b9a0) to head (3712300).

Files with missing lines Patch % Lines
flytekit/image_spec/image_spec.py 15.78% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2895      +/-   ##
==========================================
- Coverage   46.81%   46.62%   -0.19%     
==========================================
  Files         200      200              
  Lines       20901    20854      -47     
  Branches     2689     2692       +3     
==========================================
- Hits         9785     9724      -61     
- Misses      10635    10653      +18     
+ Partials      481      477       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

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.

[Core feature] Add ImageSpec.from_notebook_env
3 participants