From 617d7d338b2b61f190f4856b5bfd6c8bf6bdd1c8 Mon Sep 17 00:00:00 2001 From: Honglin <0mza987@gmail.com> Date: Tue, 19 Sep 2023 21:51:47 +0800 Subject: [PATCH] [SDK/CLI] Hide internal constants (#552) # Description Please add an informative description that covers that changes made by the pull request and link all relevant issues. # All Promptflow Contribution checklist: - [ ] **The pull request does not introduce [breaking changes]** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** ## General Guidelines and Best Practices - [ ] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes. --- docs/dev/documentation_guidelines.md | 1 + .../promptflow/azure/operations/_run_operations.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/dev/documentation_guidelines.md b/docs/dev/documentation_guidelines.md index d8890993710..fd6042b0a7b 100644 --- a/docs/dev/documentation_guidelines.md +++ b/docs/dev/documentation_guidelines.md @@ -95,6 +95,7 @@ class MyClass: - Single backticks (`): Single backticks are used to represent inline code elements within the text. It is typically used to highlight function names, variable names, or any other code elements within the documentation. - Double backticks(``): Double backticks are typically used to highlight a literal value. +8. If there are any class level constants you don't want to expose to doc site, make sure to add `_` in front of the constant to hide it. ### Write function docstring diff --git a/src/promptflow/promptflow/azure/operations/_run_operations.py b/src/promptflow/promptflow/azure/operations/_run_operations.py index e078896215e..ffee8ef14b7 100644 --- a/src/promptflow/promptflow/azure/operations/_run_operations.py +++ b/src/promptflow/promptflow/azure/operations/_run_operations.py @@ -73,8 +73,9 @@ class RunOperations(_ScopeDependentOperations): attaches it as an attribute. """ - DATASTORE_PATH_PATTERN = re.compile(r"azureml://datastores/(?P[\w/]+)/paths/(?P.*)$") - ASSET_ID_PATTERN = re.compile(r"azureml:/.*?/data/(?P.*?)/versions/(?P.*?)$") + # add "_" in front of the constant to hide them from the docstring + _DATASTORE_PATH_PATTERN = re.compile(r"azureml://datastores/(?P[\w/]+)/paths/(?P.*)$") + _ASSET_ID_PATTERN = re.compile(r"azureml:/.*?/data/(?P.*?)/versions/(?P.*?)$") def __init__( self, @@ -131,7 +132,7 @@ def _get_input_portal_url_from_input_uri(self, input_uri): return None if input_uri.startswith("azureml://"): # input uri is a datastore path - match = self.DATASTORE_PATH_PATTERN.match(input_uri) + match = self._DATASTORE_PATH_PATTERN.match(input_uri) if not match or len(match.groups()) != 2: logger.warning(error_msg) return None @@ -156,7 +157,7 @@ def _get_portal_url_from_asset_id(self, output_uri): error_msg = f"Failed to get portal url: {output_uri!r} is not a valid azureml asset id." if not output_uri: return None - match = self.ASSET_ID_PATTERN.match(output_uri) + match = self._ASSET_ID_PATTERN.match(output_uri) if not match or len(match.groups()) != 2: logger.warning(error_msg) return None