Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
import pandas as pd
from typing importOptional, Listfrom uuid import UUID
# Logging decorator from sempyfrom sempy._utils._log import log
# Helper functionsfrom sempy_labs._helper_functions import (
resolve_workspace_name_and_id,
resolve_workspace_id,
_base_api,
_create_dataframe,
)
# Icons for user messagesimport sempy_labs._icons as icons
Function Template
@logdefmy_new_function(
item: str | UUID,
workspace: Optional[str | UUID] = None,
option: str = "default",
) -> pd.DataFrame:
"""
Short description of what the function does.
Extended description with more details about the function's behavior,
use cases, and any important notes.
This is a wrapper function for the following API: `API Name <https://learn.microsoft.com/rest/api/...>`_.
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
Parameters
----------
item : str | uuid.UUID
The name or ID of the item.
workspace : str | uuid.UUID, default=None
The Fabric workspace name or ID.
Defaults to None which resolves to the workspace of the attached lakehouse
or if no lakehouse attached, resolves to the workspace of the notebook.
option : str, default="default"
An option that controls function behavior.
Returns
-------
pandas.DataFrame
A pandas dataframe showing the results.
Columns include: 'Column1', 'Column2', 'Column3'.
Raises
------
ValueError
If the item does not exist.
FabricHTTPException
If the API request fails.
"""# Resolve workspace
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
# Define result DataFrame structure
columns = {
"Column1": "string",
"Column2": "string",
"Column3": "int",
}
df = _create_dataframe(columns=columns)
# Make API call
responses = _base_api(
request=f"/v1/workspaces/{workspace_id}/items",
uses_pagination=True,
client="fabric_sp",
)
# Process responses
rows = []
for r in responses:
for item in r.get("value", []):
rows.append({
"Column1": item.get("id"),
"Column2": item.get("name"),
"Column3": item.get("count", 0),
})
if rows:
df = pd.DataFrame(rows)
return df
# tests/test_my_feature.pyimport pytest
import pandas as pd
deftest_my_new_function_returns_dataframe():
"""Test that my_new_function returns a DataFrame."""from sempy_labs import my_new_function
# This might require mocking for unit tests
result = my_new_function()
assertisinstance(result, pd.DataFrame)
deftest_my_new_function_with_workspace():
"""Test my_new_function with specific workspace."""from sempy_labs import my_new_function
result = my_new_function(workspace="Test Workspace")
assertisinstance(result, pd.DataFrame)
Step 5: Document the Function
Ensure the docstring follows numpydoc style:
✅ Short description (one line)
✅ Extended description (if needed)
✅ API reference link (for wrapper functions)
✅ Service Principal note (if supported)
✅ All parameters documented with types
✅ Return value documented
✅ Exceptions documented (if applicable)
Checklist Before Committing
Function follows naming conventions (list_, get_, create_, etc.)
@log decorator is applied
Complete docstring with numpydoc style
Type hints for all parameters and return value
Uses standard helper functions (_base_api, resolve_*, etc.)