Skip to content

Commit

Permalink
[Doc] Add flow operations to reference doc (#1846)
Browse files Browse the repository at this point in the history
# 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).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## 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.
  • Loading branch information
0mza987 authored Jan 25, 2024
1 parent 734fd79 commit 2153885
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/promptflow/promptflow/_sdk/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

from ._flow_operations import FlowOperations
from ._run_operations import RunOperations

__all__ = [
"FlowOperations",
"RunOperations",
]
3 changes: 2 additions & 1 deletion src/promptflow/promptflow/azure/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore


from ._flow_operations import FlowOperations
from ._run_operations import RunOperations

__all__ = ["RunOperations"]
__all__ = ["FlowOperations", "RunOperations"]
12 changes: 7 additions & 5 deletions src/promptflow/promptflow/azure/operations/_flow_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class FlowOperations(WorkspaceTelemetryMixin, _ScopeDependentOperations):
"""FlowOperations that can manage flows.
You should not instantiate this class directly. Instead, you should
create a :class:`~promptflow.azure.PFClient` instance that instantiates it for you and
attaches it as an attribute.
create a :class:`~promptflow.azure.PFClient` instance and this operation is available as the instance's attribute.
"""

_FLOW_RESOURCE_PATTERN = re.compile(r"azureml:.*?/workspaces/(?P<experiment_id>.*?)/flows/(?P<flow_id>.*?)$")
Expand Down Expand Up @@ -94,7 +93,10 @@ def _index_service_endpoint_url(self):

@monitor_operation(activity_name="pfazure.flows.create_or_update", activity_type=ActivityType.PUBLICAPI)
def create_or_update(self, flow: Union[str, Path], display_name=None, type=None, **kwargs) -> Flow:
"""Create a flow to remote from local source.
"""Create a flow to remote from local source, or update the metadata of an existing flow.
.. note::
Functionality of updating flow metadata is yet to be supported.
:param flow: The source of the flow to create.
:type flow: Union[str, Path]
Expand Down Expand Up @@ -314,8 +316,8 @@ def list(
:type list_view_type: ListViewType
:param include_others: Whether to list flows owned by other users in the remote workspace, defaults to False
:type include_others: bool
:return: The list of runs.
:rtype: List[~promptflow.azure. entities.Run]
:return: The list of flows.
:rtype: List[~promptflow.azure.entities.Flow]
"""
if not isinstance(max_results, int) or max_results < 1:
raise FlowOperationError(f"'max_results' must be a positive integer, got {max_results!r}")
Expand Down
11 changes: 8 additions & 3 deletions src/promptflow/promptflow/azure/operations/_run_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from promptflow.azure._constants._flow import AUTOMATIC_RUNTIME, AUTOMATIC_RUNTIME_NAME, CLOUD_RUNS_PAGE_SIZE
from promptflow.azure._load_functions import load_flow
from promptflow.azure._restclient.flow_service_caller import FlowServiceCaller
from promptflow.azure._utils.gerneral import get_user_alias_from_credential, get_authorization
from promptflow.azure._utils.gerneral import get_authorization, get_user_alias_from_credential
from promptflow.azure.operations._flow_operations import FlowOperations
from promptflow.exceptions import UserErrorException

Expand All @@ -73,8 +73,7 @@ class RunOperations(WorkspaceTelemetryMixin, _ScopeDependentOperations):
"""RunOperations that can manage runs.
You should not instantiate this class directly. Instead, you should
create an :class:`~promptflow.azure.PFClient` instance that instantiates it for you and
attaches it as an attribute.
create an :class:`~promptflow.azure.PFClient` instance and this operation is available as the instance's attribute.
"""

def __init__(
Expand Down Expand Up @@ -875,6 +874,12 @@ def download(
) -> str:
"""Download the data of a run, including input, output, snapshot and other run information.
.. note::
After the download is finished, you can use ``pf run create --source <run-info-local-folder>``
to register this run as a local run record, then you can use commands like ``pf run show/visualize``
to inspect the run just like a run that was created from local flow.
:param run: The run name or run object
:type run: Union[str, ~promptflow.entities.Run]
:param output: The output directory. Default to be default to be "~/.promptflow/.runs" folder.
Expand Down

0 comments on commit 2153885

Please sign in to comment.