### Development Environment Setup Source: https://github.com/alisonpezzott/pyfabricops/blob/main/README.md Install uv and sync development dependencies. ```bash # Install uv pip install uv # Sync dev dependencies (creates .venv automatically) uv sync --group dev ``` -------------------------------- ### Set up the development environment Source: https://github.com/alisonpezzott/pyfabricops/blob/main/CONTRIBUTING.md Install dependencies and prepare the environment using uv. ```bash # Install uv (if not already installed) pip install uv # Sync dev dependencies (creates .venv automatically) uv sync --group dev # Copy environment file cp .env.example .env ``` -------------------------------- ### Install PyFabricOps Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Install the library using pip. ```bash pip install -U pyfabricops ``` -------------------------------- ### Basic Usage Example Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/functions/utils/logging_system.md Initializes the default logging configuration before executing library functions. ```python import pyfabricops as pf # Default setup pf.setup_logging(level="INFO") # Use library normally workspaces = pf.list_workspaces() ``` -------------------------------- ### Publish and Install via TestPyPI Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Commands to build, publish to the TestPyPI repository, and install the package for verification. ```bash # Build and publish to TestPyPI uv build uv publish --publish-url https://test.pypi.org/legacy/ --token # Install from TestPyPI pip install --index-url https://test.pypi.org/simple/ pyfabricops ``` -------------------------------- ### Conventional commit examples Source: https://github.com/alisonpezzott/pyfabricops/blob/main/CONTRIBUTING.md Examples of valid commit messages using the Conventional Commits standard. ```text feat(auth): add JWT token refresh fix(api): handle empty response from upstream docs: update installation instructions ``` -------------------------------- ### Log Output Example Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/functions/utils/logging_system.md Sample output showing the standard log format with timestamps, module names, and log levels. ```text 13:00:25 | pyfabricops._core | INFO | Making GET request to https://api.fabric.microsoft.com/v1/workspaces 13:00:25 | pyfabricops._core | DEBUG | Headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ***'} 13:00:25 | pyfabricops._core | DEBUG | Response status: 200 ``` -------------------------------- ### Define Environment Variables Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Example content for a .env file to store authentication credentials. ```text FAB_CLIENT_ID=your_client_id_here FAB_CLIENT_SECRET=your_client_secret_here FAB_TENANT_ID=your_tenant_id_here FAB_USERNAME=your_username_here # Necessary for some functions with no SPN support FAB_PASSWORD=your_password_here # Necessary for some functions with no SPN support ``` -------------------------------- ### Configure Logging System Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/functions/utils/logging_system.md Basic setup and management of the logging system, including debug mode and reset functionality. ```python import pyfabricops as pf # Basic configuration pf.setup_logging(level="INFO", format_style="standard") # Debug mode for development pf.enable_debug_mode(include_external=False) # Disable logging completely pf.disable_logging() # Reset to default configuration pf.reset_logging() ``` -------------------------------- ### Initialize Service Principal Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Set the authentication provider to 'env' using the Service Principal flow, which is the default behavior. ```python import pyfabricops as pf pf.set_auth_provider("env") # default: credential_type="spn" pf.set_auth_provider("env", credential_type="spn") # explicit equivalent workspaces = pf.list_workspaces() ``` -------------------------------- ### Run linting and formatting checks Source: https://github.com/alisonpezzott/pyfabricops/blob/main/CONTRIBUTING.md Execute Ruff to check and format the codebase before committing changes. ```bash ruff check . --fix ruff format . ``` -------------------------------- ### Initialize User ROPC Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Set the authentication provider to 'env' using the ROPC flow for CI/CD environments lacking a Service Principal. Note that this is incompatible with MFA or Conditional Access. ```python import pyfabricops as pf pf.set_auth_provider("env", credential_type="user") workspaces = pf.list_workspaces() ``` -------------------------------- ### Initialize Environment Variable Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/authentication_guide.md Set the authentication provider to 'env' to use credentials stored in environment variables. ```python import pyfabricops as pf # This is the default, but you can set it explicitly pf.set_auth_provider("env") # Now use the library workspaces = pf.list_workspaces() ``` -------------------------------- ### Configure File Logging Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/functions/utils/logging_system.md Enables logging to a file with automatic rotation based on file size and backup count. ```python # Save logs to file with automatic rotation pf.setup_logging( level="DEBUG", log_file="logs/pyfabricops.log", max_file_size=10*1024*1024, # 10MB backup_count=5 ) ``` -------------------------------- ### Configure OAuth Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Use this method for local development environments like VSCode or Jupyter notebooks. It requires browser access for the initial authentication. ```python import pyfabricops as pf pf.set_auth_provider("oauth") # First call will open a browser for authentication workspaces = pf.list_workspaces() ``` -------------------------------- ### Set Authentication Provider Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Configure the authentication method for the library. Use 'env' for environment variables, 'oauth' for interactive browser login, or 'fabric' for Microsoft Fabric notebooks. ```python pf.set_auth_provider("env") ``` ```python pf.set_auth_provider("oauth") ``` ```python pf.set_auth_provider("fabric") ``` -------------------------------- ### Authenticate for CI/CD Pipelines Source: https://github.com/alisonpezzott/pyfabricops/blob/main/authentication_guide.md Use the 'env' provider to authenticate via service principal credentials stored in environment variables. ```python import pyfabricops as pf import os # Use env method with service principal pf.set_auth_provider("env") # Credentials come from environment variables # These should be set in GitHub Secrets or Azure DevOps variables workspaces = pf.list_workspaces() # Deploy items pf.deploy_item("my-workspace", "my-item", source_path="./artifacts") ``` -------------------------------- ### Switch Authentication Methods at Runtime Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Dynamically change the authentication provider during execution to accommodate different operational contexts. ```python import pyfabricops as pf # Start with OAuth pf.set_auth_provider("oauth") workspaces = pf.list_workspaces() # Switch to env for deployment pf.set_auth_provider("env") pf.deploy_item("workspace", "item", "./path") # Switch to fabric if in Fabric notebook try: pf.set_auth_provider("fabric") print("Running in Fabric!") except Exception: print("Not in Fabric, using current method") ``` -------------------------------- ### Configure OAuth for Local Development Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Use the OAuth provider for interactive local development sessions. ```python import pyfabricops as pf # Use OAuth for easy local development pf.set_auth_provider("oauth") pf.setup_logging(level="info") workspaces = pf.list_workspaces() print(f"Found {len(workspaces)} workspaces") ``` -------------------------------- ### Production Logging Configuration Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/functions/utils/logging_system.md Configures minimal logging for production environments, disabling colors and directing output to a specific file. ```python # Minimal logging in production pf.setup_logging( level="WARNING", format_style="minimal", include_colors=False, log_file="/var/log/app/pyfabricops.log" ) ``` -------------------------------- ### Configure User-based Environment Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Switches to the ROPC flow for environment-based authentication, requiring FAB_USERNAME and FAB_PASSWORD. ```python pf.set_auth_provider("env", credential_type="user") # Requires FAB_USERNAME and FAB_PASSWORD in the environment ``` -------------------------------- ### Configure Environment Variables for Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Define required credentials in a .env file or system environment variables for Service Principal or ROPC flows. ```env FAB_CLIENT_ID=your_client_id_here FAB_CLIENT_SECRET=your_client_secret_here # Required for SPN flow FAB_TENANT_ID=your_tenant_id_here FAB_USERNAME=your_username_here # Required for user (ROPC) flow FAB_PASSWORD=your_password_here # Required for user (ROPC) flow ``` -------------------------------- ### Configure CI/CD Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Use environment-based authentication for automated pipelines, supporting both Service Principal and ROPC flows. ```python import pyfabricops as pf import os # Use env method with service principal (default) pf.set_auth_provider("env") # Credentials come from environment variables # These should be set in GitHub Secrets or Azure DevOps variables workspaces = pf.list_workspaces() # Deploy items pf.deploy_item("my-workspace", "my-item", source_path="./artifacts") ``` ```python import pyfabricops as pf # Use ROPC flow when a Service Principal is not available pf.set_auth_provider("env", credential_type="user") # FAB_USERNAME and FAB_PASSWORD must be set in the environment workspaces = pf.list_workspaces() ``` -------------------------------- ### Import PyFabricOps Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Import the library into your Python script or notebook. ```python # Import the library import pyfabricops as pf ``` -------------------------------- ### Project Directory Structure Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Visual representation of the pyfabricops source code organization. ```bash src/ └── pyfabricops/ ├── api/ │ ├── __init__.py │ ├── api.py │ ├── auth.py │ └── scopes.py ├── cd/ │ ├── __init__.py │ └── support_files.py ├── core/ │ ├── __init__.py │ ├── capacities.py │ ├── connections.py │ ├── deployment_pipelines.py │ ├── domains.py │ ├── folders.py │ ├── gateways.py │ ├── gateways_encryp_creds.py │ ├── git.py │ ├── tags.py │ └── workspaces.py ├── dmv/ │ ├── __init__.py │ └── dmv.py ├── graph/ │ ├── __init__.py │ └── users.py ├── helpers/ │ ├── __init__.py │ ├── data_pipelines.py │ ├── data_pipelines.py │ ├── dataflows_gen1.py │ ├── dataflows_gen2.py │ ├── environments.py │ ├── folders.py │ ├── items.py │ ├── lakehouses.py │ ├── notebooks.py │ ├── reports.py │ ├── semantic_models.py │ ├── warehouses.py │ └── workspaces.py ├── items/ │ ├── __init__.py │ ├── data_pipelines.py │ ├── dataflows_gen1.py │ ├── dataflows_gen2.py │ ├── environments.py │ ├── items.py │ ├── lakehouses.py │ ├── notebooks.py │ ├── reports.py │ ├── semantic_models.py │ ├── shortcuts.py │ ├── spark.py │ ├── variable_libraries.py │ └── warehouses.py ├── utils/ │ ├── __init__.py │ ├── decorators.py │ ├── exceptions.py │ ├── logging.py │ ├── schemas.py │ └── utils.py ├── __init__.py └── _version.py ``` -------------------------------- ### Configure Fabric-native Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Utilize the fabric provider when running code directly within a Fabric notebook, requiring no explicit credentials. ```python import pyfabricops as pf # Use fabric method - no credentials needed! pf.set_auth_provider("fabric") # Get current workspace info workspace = pf.get_workspace("my-workspace-name") print(workspace) # List items items = pf.list_items(workspace["id"]) for item in items: print(f"- {item['displayName']} ({item['type']})") ``` -------------------------------- ### Verify Environment Variables Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Checks for the presence of required environment variables for the env authentication method. ```python import os print("Client ID:", os.getenv("FAB_CLIENT_ID")) print("Tenant ID:", os.getenv("FAB_TENANT_ID")) ``` -------------------------------- ### Configure Branch Mappings Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/index.md Define branch mappings in a branches.json file to manage CI/CD branch naming conventions. ```json { "main": "-PRD", "master": "-PRD", "dev": "-DEV", "develop": "-DEV", "staging": "-STG" } ``` -------------------------------- ### Set Authentication Provider Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Configures the authentication provider when running outside of a Microsoft Fabric notebook. ```python pf.set_auth_provider("oauth") # or "env" ``` -------------------------------- ### Configure Fabric Notebook Authentication Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Use this method when running code directly inside Microsoft Fabric notebooks. It automatically retrieves the authenticated user's token. ```python import pyfabricops as pf pf.set_auth_provider("fabric") # Uses the authenticated user's token automatically workspaces = pf.list_workspaces() ``` ```python from notebookutils import credentials access_token = credentials.getToken("pbi") ``` -------------------------------- ### Create a new feature branch Source: https://github.com/alisonpezzott/pyfabricops/blob/main/CONTRIBUTING.md Use this command to create a new branch from the main branch for your feature development. ```bash git checkout -b feat/your-feature-name ``` -------------------------------- ### Development and Debug Usage Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/functions/utils/logging_system.md Enables verbose debug logging to trace API calls and internal operations. ```python # Complete debug mode pf.enable_debug_mode(include_external=True) # Execute functions - you'll see all API details definition = pf.get_semantic_model_definition("workspace", "model") ``` -------------------------------- ### Conventional commit format Source: https://github.com/alisonpezzott/pyfabricops/blob/main/CONTRIBUTING.md The structure required for commit messages following Conventional Commits. ```text (optional scope): [optional body] [optional footer] ``` -------------------------------- ### Clear Token Cache Source: https://github.com/alisonpezzott/pyfabricops/blob/main/docs/authentication_guide.md Clears the existing token cache to resolve authentication issues before re-authenticating. ```python pf.clear_token_cache() pf.set_auth_provider("oauth") # Re-authenticate ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.