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

SNOW-919476: Do not ignore stage location for using imports when is_permanent is False #1053

Conversation

sfc-gh-aalam
Copy link
Contributor

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #SNOW-919476

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

@sfc-gh-aalam sfc-gh-aalam marked this pull request as ready for review September 21, 2023 01:35
@sfc-gh-aalam sfc-gh-aalam requested a review from a team as a code owner September 21, 2023 01:35
@sfc-gh-aalam
Copy link
Contributor Author

PR for fixing the merge-gate failures is here: #1054

Copy link
Collaborator

@sfc-gh-sfan sfc-gh-sfan left a comment

Choose a reason for hiding this comment

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

I'm not sure if this is the desired behavior (e.g. upload the udf zip file into a permanent stage location for a temp UDF). Can we instead separate the concern of upload and imports? For example, we could have an upload stage and an import stage.

@sfc-gh-aalam
Copy link
Contributor Author

sfc-gh-aalam commented Sep 22, 2023

I'm not sure if this is the desired behavior (e.g. upload the udf zip file into a permanent stage location for a temp UDF). Can we instead separate the concern of upload and imports? For example, we could have an upload stage and an import stage.

This is a really good suggestion. I have updated the code to use this logic because I got confused about the context and started looking at stage location only as an upload location.

This is the desired behavior from temp sprocs:

  • temp sprocs should not upload packages to permanent stages
  • temp sprocs should be able to import pacakges from permanent stages
  • temp sprocs should be able to use custom packages using imports
  • temp sprocs should be able to import files from permanent stage and also use custom packages from imports

Comment on lines 701 to 702
# probably shouldn't do it. It is already done in resolve_imports_and_pacakges
normalized_import_location = unwrap_stage_location_single_quote(import_stage)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we verify if this could lead to bugs (e.g. over-unwrapping)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are some tests in test_utils_suite.py/test_normalize_stage_location which test for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added more tests. Overwrapping does not lead to bugs

@sfc-gh-sfan
Copy link
Collaborator

This is the desired behavior from temp sprocs:

  • temp sprocs should not upload packages to permanent stages
  • temp sprocs should be able to import pacakges from permanent stages
  • temp sprocs should be able to use custom packages using imports
  • temp sprocs should be able to import files from permanent stage and also use custom packages from imports

Let's make sure this is documented and tested :)

@sfc-gh-aalam
Copy link
Contributor Author

This is the desired behavior from temp sprocs:

  • temp sprocs should not upload packages to permanent stages
  • temp sprocs should be able to import pacakges from permanent stages
  • temp sprocs should be able to use custom packages using imports
  • temp sprocs should be able to import files from permanent stage and also use custom packages from imports

Let's make sure this is documented and tested :)

Yep. I'm working on the tests now.

@@ -821,6 +816,12 @@ def resolve_imports_and_packages(
else session.get_session_stage()
)

import_stage = (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's define import_stage first then upload_stage = import_stage if is_permanent else session_stage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if there's a better name for upload_stage, because technically we need to upload files to import_stage too. How about something like sproc_stage vs import_stage?
In addition, could you please add a one line documentation for these args to clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with your point but the stage is used for udfs as well. How about import_only_stage and upload_and_import_stage?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we upload files to import stage, but it is the other way around (we import the upload stage). And as Afroz mentioned, the import/upload difference is application to UDF families as well. I cannot come up with a better name than what Afroz suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

stage_location, statement_params=statement_params
import_only_stage, statement_params=statement_params
)
# probably shouldn't do it. It is already done in resolve_imports_and_pacakges
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove this comment if we already have tests :p

@sfc-gh-aalam sfc-gh-aalam enabled auto-merge (squash) September 28, 2023 20:26
@sfc-gh-aalam sfc-gh-aalam merged commit 00ca832 into main Sep 28, 2023
49 of 50 checks passed
@sfc-gh-aalam sfc-gh-aalam deleted the aalam-SNOW-919476-temporaray-sp-cant-use-permanent-stage-location branch September 28, 2023 21:44
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants