Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions azure/durable_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,50 @@
from .models.DurableEntityContext import DurableEntityContext
from .models.RetryOptions import RetryOptions
from .models.TokenSource import ManagedIdentityTokenSource
import json
from pathlib import Path
import sys


def validate_extension_bundles():
"""Throw an exception if host.json contains bundle-range V1.

Raises
------
Exception: Exception prompting the user to update to bundles V2
"""
# No need to validate if we're running tests
if "pytest" in sys.modules:
return

host_path = "host.json"
bundles_key = "extensionBundle"
version_key = "version"
host_file = Path(host_path)

if not host_file.exists():
# If it doesn't exist, we ignore it
return

with open(host_path) as f:
host_settings = json.loads(f.read())
try:
version_range = host_settings[bundles_key][version_key]
except Exception:
# If bundle info is not available, we ignore it.
# For example: it's possible the user is using a manual extension install
return
# We do a best-effort attempt to detect bundles V1
# This is the string hard-coded into the bundles V1 template in VSCode
if version_range == "[1.*, 2.0.0)":

Choose a reason for hiding this comment

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

I think some small subset of customers may have more specific version ranges, like "[1.2, 2.0.0)" due to pinning during regressions. It's an edge case, but we may want to ask @narensoni if we should cover it.

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'll merge this for now, since it's better than nothing, but track this follow-up here: #247

message = "Durable Functions for Python does not support Bundles V1."\
" Please update to Bundles V2 in your `host.json`."\
" You can set extensionBundles version to be: [2.*, 3.0.0)"
raise Exception(message)


# Validate that users are not in extension bundles V1
validate_extension_bundles()

__all__ = [
'Orchestrator',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from setuptools import setup, find_packages
from distutils.command import build

with open("README.md", "r") as fh:
with open("README.md", "r", encoding="utf8") as fh:
long_description = fh.read()

class BuildModule(build.build):
Expand Down