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

implement metrics counter feature tracking for NADE #1597

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-mchok
Copy link
Collaborator

@sfc-gh-mchok sfc-gh-mchok commented Sep 19, 2024

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

  • Implement basic metrics and counter objects for additional telemetry capabilities
  • Instrument relevant NADE code for feature adoption tracking

@sfc-gh-mchok sfc-gh-mchok self-assigned this Sep 19, 2024
@sfc-gh-mchok sfc-gh-mchok marked this pull request as ready for review September 19, 2024 20:48
@sfc-gh-mchok sfc-gh-mchok requested review from a team as code owners September 19, 2024 20:48
@sfc-gh-mchok sfc-gh-mchok removed the 3.0 label Sep 19, 2024
TEMPLATES_PROCESSOR = f"{_FEATURES_PREFIX}.templates_processor"
SQL_TEMPLATES = f"{_FEATURES_PREFIX}.sql_templates"
PDF_TEMPLATES = f"{_FEATURES_PREFIX}.pdf_templates"
SNOWPARK_PROCESSOR = f"{_FEATURES_PREFIX}.{_APP_PREFIX}.snowpark_processor"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if we should switch these, so app comes first, so we can separate these easily? @sfc-gh-bdufour , @sfc-gh-turbaszek wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

What's here makes sense to me, I don't think I understand the suggestion. Can you explain?

src/snowflake/cli/api/utils/definition_rendering.py Outdated Show resolved Hide resolved
@@ -340,6 +342,18 @@ def render_definition_template(
project_context[CONTEXT_KEY]["env"] = environment_overrides
return ProjectProperties(project_definition, project_context)

has_user_referenced_vars = (
Copy link
Contributor

Choose a reason for hiding this comment

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

can we put this whole new logic into a function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also refactored the usage here with this function, let me know if this works for you!

@@ -340,6 +342,18 @@ def render_definition_template(
project_context[CONTEXT_KEY]["env"] = environment_overrides
return ProjectProperties(project_definition, project_context)

has_user_referenced_vars = (
len(_get_referenced_vars_in_definition(template_env, definition)) > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a risk/side effect from calling this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went through the called functions and i do not believe there should be any, unless self._jinja_env.parse has side effects?

Copy link
Contributor

Choose a reason for hiding this comment

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

it could throw error, but I guess it will throw them later anyways

@sfc-gh-bdufour
Copy link
Contributor

sfc-gh-bdufour commented Sep 20, 2024

I think this will require a fair amount of rework before being checked in, I'll do a full pass tomorrow though. Just to clarify, this is a not a target for inclusion in the 3.0 release (cc @sfc-gh-turbaszek)

# See the License for the specific language governing permissions and
# limitations under the License.

from snowflake.snowpark.functions import sproc, udf
Copy link
Contributor

Choose a reason for hiding this comment

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

it was an explicit choice to do this in E2E tests and not integ. That's because it didn't seem right to rely on the fact that the CLI is currently bundling the snowpark lib, or which version it's using. It's a bit more of an implementation detail IMHO. In E2E though, we get to install the snowpark lib in the test environment, so that's a lot more robust.

TEMPLATES_PROCESSOR = f"{_FEATURES_PREFIX}.templates_processor"
SQL_TEMPLATES = f"{_FEATURES_PREFIX}.sql_templates"
PDF_TEMPLATES = f"{_FEATURES_PREFIX}.pdf_templates"
SNOWPARK_PROCESSOR = f"{_FEATURES_PREFIX}.{_APP_PREFIX}.snowpark_processor"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's here makes sense to me, I don't think I understand the suggestion. Can you explain?

Comment on lines +37 to +40
def __eq__(self, other):
if isinstance(other, CLIMetrics):
return self._counters == other._counters
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this?

def set_counter(self, name: str, value: int) -> None:
self._counters[name] = value

def add_counter(self, name: str, value: int) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: increment_counter
nit: optional value = 1

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