dagster-omni 0.28.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ from dagster_shared.libraries import DagsterLibraryRegistry
2
+
3
+ from dagster_omni.component import OmniComponent as OmniComponent
4
+ from dagster_omni.version import __version__ as __version__
5
+
6
+ DagsterLibraryRegistry.register("dagster-omni", __version__)
@@ -0,0 +1,186 @@
1
+ import itertools
2
+ from collections import defaultdict
3
+ from pathlib import Path
4
+ from typing import Optional
5
+
6
+ import dagster as dg
7
+ from dagster._annotations import preview, public
8
+ from dagster._core.errors import DagsterInvalidDefinitionError
9
+ from dagster.components.component.state_backed_component import StateBackedComponent
10
+ from dagster.components.utils.defs_state import (
11
+ DefsStateConfig,
12
+ DefsStateConfigArgs,
13
+ ResolvedDefsStateConfig,
14
+ )
15
+ from pydantic import Field
16
+
17
+ from dagster_omni.objects import OmniDocument, OmniQuery, OmniWorkspaceData
18
+ from dagster_omni.translation import (
19
+ TRANSLATOR_DATA_METADATA_KEY,
20
+ OmniDocumentMetadataSet,
21
+ OmniTranslatorData,
22
+ ResolvedOmniTranslationFn,
23
+ )
24
+ from dagster_omni.workspace import OmniWorkspace
25
+
26
+
27
+ @preview
28
+ class OmniComponent(StateBackedComponent, dg.Model, dg.Resolvable):
29
+ """Pulls in the contents of an Omni workspace into Dagster assets.
30
+
31
+ Example:
32
+
33
+ .. code-block:: yaml
34
+
35
+ # defs.yaml
36
+
37
+ type: dagster_omni.OmniComponent
38
+ attributes:
39
+ workspace:
40
+ base_url: https://your-company.omniapp.co
41
+ api_key: "{{ env.OMNI_API_KEY }}"
42
+ """
43
+
44
+ workspace: OmniWorkspace = Field(
45
+ description="Defines configuration for interacting with an Omni instance.",
46
+ )
47
+ translation: Optional[ResolvedOmniTranslationFn] = Field(
48
+ default=None,
49
+ description="Defines how to translate an Omni object into an AssetSpec object.",
50
+ )
51
+ defs_state: ResolvedDefsStateConfig = DefsStateConfigArgs.versioned_state_storage()
52
+
53
+ @property
54
+ def defs_state_config(self) -> DefsStateConfig:
55
+ return DefsStateConfig.from_args(self.defs_state, default_key=self.__class__.__name__)
56
+
57
+ async def write_state_to_path(self, state_path: Path) -> None:
58
+ """Fetch documents from Omni API and write state to path."""
59
+ state = await self.workspace.fetch_omni_state()
60
+ state_path.write_text(dg.serialize_value(state))
61
+
62
+ def load_state_from_path(self, state_path: Path) -> OmniWorkspaceData:
63
+ """Load state from path using Dagster's deserialization system."""
64
+ return dg.deserialize_value(state_path.read_text(), OmniWorkspaceData)
65
+
66
+ def _get_default_omni_spec(
67
+ self, context: dg.ComponentLoadContext, data: OmniTranslatorData, workspace: OmniWorkspace
68
+ ) -> Optional[dg.AssetSpec]:
69
+ """Core function for converting an Omni document into an AssetSpec object."""
70
+ if isinstance(data.obj, OmniDocument):
71
+ doc = data.obj
72
+ maybe_deps = [
73
+ self.get_asset_spec(
74
+ context, OmniTranslatorData(obj=query, workspace_data=data.workspace_data)
75
+ )
76
+ for query in data.obj.queries
77
+ ]
78
+
79
+ prefix = doc.folder.path.split("/") if doc.folder else []
80
+ user = data.workspace_data.get_user(doc.owner.id)
81
+ owner_email = user.primary_email if user else None
82
+
83
+ return dg.AssetSpec(
84
+ key=dg.AssetKey([*prefix, doc.name]),
85
+ group_name=prefix[0].replace("-", "_") if prefix else None,
86
+ tags={label.name: "" for label in doc.labels},
87
+ deps=list(filter(None, maybe_deps)),
88
+ metadata={
89
+ **OmniDocumentMetadataSet.from_document(workspace, doc),
90
+ TRANSLATOR_DATA_METADATA_KEY: data,
91
+ },
92
+ kinds={"omni"},
93
+ owners=[owner_email] if owner_email else None,
94
+ )
95
+ if isinstance(data.obj, OmniQuery):
96
+ return dg.AssetSpec(key=dg.AssetKey([data.obj.query_config.table]))
97
+ return None
98
+
99
+ @public
100
+ def get_asset_spec(
101
+ self, context: dg.ComponentLoadContext, data: OmniTranslatorData
102
+ ) -> Optional[dg.AssetSpec]:
103
+ """Generates an AssetSpec for a given Omni document.
104
+
105
+ This method can be overridden in a subclass to customize how Omni documents
106
+ (workbooks, queries) are converted to Dagster asset specs. By default, it applies
107
+ any configured translation function to the base asset spec.
108
+
109
+ Args:
110
+ context: The component load context provided by Dagster
111
+ data: The OmniTranslatorData containing information about the Omni document
112
+
113
+ Returns:
114
+ An AssetSpec that represents the Omni document as a Dagster asset, or None
115
+ if the document should not be represented as an asset
116
+
117
+ Example:
118
+ Override this method to add custom metadata based on document properties:
119
+
120
+ .. code-block:: python
121
+
122
+ from dagster_omni import OmniComponent
123
+ import dagster as dg
124
+
125
+ class CustomOmniComponent(OmniComponent):
126
+ def get_asset_spec(self, context, data):
127
+ base_spec = super().get_asset_spec(context, data)
128
+ if base_spec:
129
+ return base_spec.replace_attributes(
130
+ metadata={
131
+ **base_spec.metadata,
132
+ "omni_type": type(data.obj).__name__,
133
+ "workspace": data.workspace_data.workspace_id
134
+ }
135
+ )
136
+ return None
137
+ """
138
+ base_asset_spec = self._get_default_omni_spec(context, data, self.workspace)
139
+ if self.translation and base_asset_spec:
140
+ return self.translation(base_asset_spec, data)
141
+ else:
142
+ return base_asset_spec
143
+
144
+ def _build_asset_specs(
145
+ self, context: dg.ComponentLoadContext, workspace_data: OmniWorkspaceData
146
+ ) -> list[dg.AssetSpec]:
147
+ """Invokes the `get_asset_spec` method on all objects in the provided `workspace_data`.
148
+ Filters out any cases where the asset_spec is `None`, and provides a helpful error
149
+ message in cases where keys overlap between different documents.
150
+ """
151
+ maybe_specs = [
152
+ self.get_asset_spec(context, OmniTranslatorData(obj=doc, workspace_data=workspace_data))
153
+ for doc in workspace_data.documents
154
+ ]
155
+
156
+ specs_by_key: dict[dg.AssetKey, list[dg.AssetSpec]] = defaultdict(list)
157
+ for spec in filter(None, maybe_specs):
158
+ specs_by_key[spec.key].append(spec)
159
+
160
+ for key, specs in specs_by_key.items():
161
+ if len(specs) == 1:
162
+ continue
163
+
164
+ ids = [OmniDocumentMetadataSet.extract(spec.metadata).url or spec for spec in specs]
165
+ ids_str = "\n\t".join(map(str, ids))
166
+ raise DagsterInvalidDefinitionError(
167
+ f"Multiple objects map to the same key {key}:"
168
+ f"\n\t{ids_str}\n"
169
+ "Please ensure that each object has a unique name by updating the `translation` function."
170
+ )
171
+
172
+ return list(itertools.chain.from_iterable(specs_by_key.values()))
173
+
174
+ def build_defs_from_workspace_data(
175
+ self, context: dg.ComponentLoadContext, workspace_data: OmniWorkspaceData
176
+ ) -> dg.Definitions:
177
+ return dg.Definitions(assets=self._build_asset_specs(context, workspace_data))
178
+
179
+ def build_defs_from_state(
180
+ self, context: dg.ComponentLoadContext, state_path: Optional[Path]
181
+ ) -> dg.Definitions:
182
+ if state_path is None:
183
+ return dg.Definitions()
184
+
185
+ state = self.load_state_from_path(state_path)
186
+ return self.build_defs_from_workspace_data(context, state)
@@ -0,0 +1,180 @@
1
+ from functools import cached_property
2
+ from typing import Any, Optional
3
+
4
+ from dagster_shared.record import record
5
+ from dagster_shared.serdes import whitelist_for_serdes
6
+
7
+
8
+ @whitelist_for_serdes
9
+ @record
10
+ class OmniFolder:
11
+ id: str
12
+ name: str
13
+ path: str
14
+ scope: str
15
+
16
+ @classmethod
17
+ def from_json(cls, data: dict[str, Any]) -> "OmniFolder":
18
+ """Create OmniFolder from JSON response data."""
19
+ return cls(id=data["id"], name=data["name"], path=data["path"], scope=data["scope"])
20
+
21
+
22
+ @whitelist_for_serdes
23
+ @record
24
+ class OmniLabel:
25
+ name: str
26
+ verified: bool
27
+
28
+ @classmethod
29
+ def from_json(cls, data: dict[str, Any]) -> "OmniLabel":
30
+ """Create OmniLabel from JSON response data."""
31
+ return cls(name=data["name"], verified=data["verified"])
32
+
33
+
34
+ @whitelist_for_serdes
35
+ @record
36
+ class OmniOwner:
37
+ id: str
38
+ name: str
39
+
40
+ @classmethod
41
+ def from_json(cls, data: dict[str, Any]) -> "OmniOwner":
42
+ """Create OmniOwner from JSON response data."""
43
+ return cls(id=data["id"], name=data["name"])
44
+
45
+
46
+ @whitelist_for_serdes
47
+ @record
48
+ class OmniDocument:
49
+ identifier: str
50
+ name: str
51
+ scope: str
52
+ connection_id: str
53
+ deleted: bool
54
+ has_dashboard: bool
55
+ type: str
56
+ updated_at: str
57
+ owner: OmniOwner
58
+ folder: Optional[OmniFolder]
59
+ labels: list[OmniLabel]
60
+ queries: list["OmniQuery"]
61
+ favorites: Optional[int] = None
62
+ views: Optional[int] = None
63
+
64
+ @classmethod
65
+ def from_json(cls, data: dict[str, Any], queries: list["OmniQuery"]) -> "OmniDocument":
66
+ """Create OmniDocument from JSON response data."""
67
+ folder = None
68
+ if data.get("folder"):
69
+ folder = OmniFolder.from_json(data["folder"])
70
+
71
+ labels = [OmniLabel.from_json(label_data) for label_data in data.get("labels", [])]
72
+ owner = OmniOwner.from_json(data["owner"])
73
+
74
+ return cls(
75
+ identifier=data["identifier"],
76
+ name=data["name"],
77
+ scope=data["scope"],
78
+ connection_id=data["connectionId"],
79
+ deleted=data["deleted"],
80
+ has_dashboard=data["hasDashboard"],
81
+ type=data.get("type", "document"),
82
+ updated_at=data["updatedAt"],
83
+ owner=owner,
84
+ folder=folder,
85
+ labels=labels,
86
+ queries=queries,
87
+ favorites=data.get("_count", {}).get("favorites", None),
88
+ views=data.get("_count", {}).get("views", None),
89
+ )
90
+
91
+
92
+ @whitelist_for_serdes
93
+ @record
94
+ class OmniQueryConfig:
95
+ """Represents the essential query configuration needed for asset creation."""
96
+
97
+ table: str
98
+ fields: list[str]
99
+
100
+ @classmethod
101
+ def from_json(cls, data: dict[str, Any]) -> "OmniQueryConfig":
102
+ """Create OmniQueryConfig from JSON query configuration data."""
103
+ return cls(
104
+ table=data["table"],
105
+ fields=data["fields"],
106
+ )
107
+
108
+
109
+ @whitelist_for_serdes
110
+ @record
111
+ class OmniQuery:
112
+ id: str
113
+ name: str
114
+ query_config: OmniQueryConfig
115
+
116
+ @classmethod
117
+ def from_json(cls, data: dict[str, Any]) -> "OmniQuery":
118
+ """Create OmniQuery from JSON response data."""
119
+ return cls(
120
+ id=data["id"],
121
+ name=data["name"],
122
+ query_config=OmniQueryConfig.from_json(data["query"]),
123
+ )
124
+
125
+
126
+ @whitelist_for_serdes
127
+ @record
128
+ class OmniUser:
129
+ """Represents an Omni user with all user information in a single class."""
130
+
131
+ id: str
132
+ name: Optional[str]
133
+ display_name: str
134
+ user_name: str
135
+ active: bool
136
+ primary_email: Optional[str]
137
+ groups: list[str]
138
+ created: str
139
+ last_modified: str
140
+
141
+ @classmethod
142
+ def from_json(cls, data: dict[str, Any]) -> "OmniUser":
143
+ """Create OmniUser from JSON response data."""
144
+ primary_email = next(
145
+ (email["value"] for email in data.get("emails", []) if email["primary"]), None
146
+ )
147
+ groups = [group["display"] for group in data.get("groups", [])]
148
+
149
+ return cls(
150
+ id=data["id"],
151
+ name=data.get("displayName") or data.get("userName") or "",
152
+ display_name=data.get("displayName", ""),
153
+ user_name=data.get("userName", ""),
154
+ active=data.get("active", True),
155
+ primary_email=primary_email,
156
+ groups=groups,
157
+ created=data.get("meta", {}).get("created", ""),
158
+ last_modified=data.get("meta", {}).get("lastModified", ""),
159
+ )
160
+
161
+
162
+ @whitelist_for_serdes
163
+ @record
164
+ class OmniWorkspaceData:
165
+ """Serializable container object for recording the state of the Omni API at a given point in time.
166
+
167
+ Properties:
168
+ documents: list[OmniDocument]
169
+ users: list[OmniUser]
170
+ """
171
+
172
+ documents: list[OmniDocument]
173
+ users: list[OmniUser]
174
+
175
+ @cached_property
176
+ def _users_by_id(self) -> dict[str, OmniUser]:
177
+ return {user.id: user for user in self.users}
178
+
179
+ def get_user(self, user_id: str) -> Optional[OmniUser]:
180
+ return self._users_by_id.get(user_id)
dagster_omni/py.typed ADDED
@@ -0,0 +1 @@
1
+ partial
@@ -0,0 +1,143 @@
1
+ from typing import Annotated, Optional, TypeAlias, Union
2
+
3
+ import dateutil
4
+ from dagster._core.definitions.assets.definition.asset_spec import AssetSpec
5
+ from dagster._core.definitions.metadata.metadata_set import NamespacedMetadataSet
6
+ from dagster._core.definitions.metadata.metadata_value import (
7
+ TimestampMetadataValue,
8
+ UrlMetadataValue,
9
+ )
10
+ from dagster.components import Resolvable, Resolver
11
+ from dagster.components.resolved.base import resolve_fields
12
+ from dagster.components.resolved.context import ResolutionContext
13
+ from dagster.components.resolved.core_models import AssetSpecKeyUpdateKwargs, AssetSpecUpdateKwargs
14
+ from dagster.components.utils import TranslatorResolvingInfo
15
+ from dagster.components.utils.translation import TranslationFn, TranslationFnResolver
16
+ from dagster_shared.record import record
17
+ from typing_extensions import Self
18
+
19
+ from dagster_omni.objects import OmniDocument, OmniQuery, OmniWorkspaceData
20
+ from dagster_omni.workspace import OmniWorkspace
21
+
22
+ TRANSLATOR_DATA_METADATA_KEY = ".dagster-omni/translator_data"
23
+
24
+
25
+ class OmniDocumentMetadataSet(NamespacedMetadataSet):
26
+ """Represents metadata that is captured from an Omni document."""
27
+
28
+ url: Optional[UrlMetadataValue] = None
29
+ owner_name: str
30
+ document_name: str
31
+ document_type: str
32
+ updated_at: TimestampMetadataValue
33
+ favorites: Optional[int] = None
34
+ views: Optional[int] = None
35
+
36
+ @classmethod
37
+ def from_document(cls, workspace: OmniWorkspace, document: OmniDocument) -> Self:
38
+ url_str = f"{workspace.base_url.rstrip('/')}/dashboards/{document.identifier}"
39
+
40
+ return cls(
41
+ url=UrlMetadataValue(url_str) if document.has_dashboard else None,
42
+ document_name=document.name,
43
+ document_type=document.type,
44
+ updated_at=TimestampMetadataValue(
45
+ dateutil.parser.parse(document.updated_at).timestamp()
46
+ ),
47
+ owner_name=document.owner.name,
48
+ favorites=document.favorites,
49
+ views=document.views,
50
+ )
51
+
52
+ @classmethod
53
+ def namespace(cls) -> str:
54
+ return "dagster-omni"
55
+
56
+
57
+ @record
58
+ class OmniTranslatorData:
59
+ """Container class for data required to translate an object in an
60
+ Omni workspace into a Dagster definition.
61
+
62
+ Properties:
63
+ obj (Union[OmniDocument, OmniQuery]): The object to translate.
64
+ workspace_data (OmniWorkspaceData): Global workspace data.
65
+ """
66
+
67
+ obj: Union[OmniDocument, OmniQuery]
68
+ workspace_data: OmniWorkspaceData
69
+
70
+
71
+ def _resolve_multilayer_translation(context: ResolutionContext, model):
72
+ """The Omni translation schema supports defining global transforms
73
+ as well as per-object-type transforms. This resolver composes the
74
+ per-object-type transforms with the global transforms.
75
+ """
76
+ info = TranslatorResolvingInfo(
77
+ asset_attributes=model,
78
+ resolution_context=context,
79
+ model_key="translation",
80
+ )
81
+
82
+ def _translation_fn(base_asset_spec: AssetSpec, data: OmniTranslatorData):
83
+ processed_spec = info.get_asset_spec(
84
+ base_asset_spec,
85
+ {
86
+ "data": data,
87
+ "spec": base_asset_spec,
88
+ },
89
+ )
90
+
91
+ nested_translation_fns = resolve_fields(
92
+ model=model,
93
+ resolved_cls=OmniTranslationArgs,
94
+ context=context.with_scope(
95
+ **{
96
+ "data": data,
97
+ "spec": processed_spec,
98
+ }
99
+ ),
100
+ )
101
+ for_document = nested_translation_fns.get("for_document")
102
+ for_query = nested_translation_fns.get("for_query")
103
+
104
+ if isinstance(data.obj, OmniDocument) and for_document:
105
+ return for_document(processed_spec, data)
106
+ if isinstance(data.obj, OmniQuery) and for_query:
107
+ return for_query(processed_spec, data)
108
+
109
+ return processed_spec
110
+
111
+ return _translation_fn
112
+
113
+
114
+ OmniTranslationFn: TypeAlias = TranslationFn[OmniTranslatorData]
115
+
116
+ ResolvedTargetedOmniTranslationFn = Annotated[
117
+ OmniTranslationFn,
118
+ TranslationFnResolver[OmniTranslatorData](lambda data: {"data": data}),
119
+ ]
120
+
121
+ ResolvedTargetedKeyOnlyOmniTranslationFn = Annotated[
122
+ OmniTranslationFn,
123
+ TranslationFnResolver[OmniTranslatorData](
124
+ lambda data: {"data": data}, model_field_type=AssetSpecKeyUpdateKwargs.model()
125
+ ),
126
+ ]
127
+
128
+
129
+ @record
130
+ class OmniTranslationArgs(AssetSpecUpdateKwargs, Resolvable):
131
+ """Model used to allow per-object-type translation of an Omni object."""
132
+
133
+ for_document: Optional[ResolvedTargetedOmniTranslationFn] = None
134
+ for_query: Optional[ResolvedTargetedKeyOnlyOmniTranslationFn] = None
135
+
136
+
137
+ ResolvedOmniTranslationFn = Annotated[
138
+ OmniTranslationFn,
139
+ Resolver(
140
+ _resolve_multilayer_translation,
141
+ model_field_type=Union[str, OmniTranslationArgs.model()],
142
+ ),
143
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.28.5"
@@ -0,0 +1,156 @@
1
+ import asyncio
2
+ import urllib.parse
3
+ from typing import Any, Optional
4
+
5
+ import aiohttp
6
+ import dagster as dg
7
+ from aiohttp.client_exceptions import ClientResponseError
8
+ from dagster._utils.backoff import async_backoff, exponential_delay_generator
9
+ from pydantic import Field
10
+
11
+ from dagster_omni.objects import OmniDocument, OmniQuery, OmniUser, OmniWorkspaceData
12
+
13
+
14
+ class OmniWorkspace(dg.Resolvable, dg.Model):
15
+ """Handles all interactions with the Omni API to fetch and manage state."""
16
+
17
+ base_url: str = Field(
18
+ description="The base URL to your Omni instance.", examples=["https://acme.omniapp.co"]
19
+ )
20
+ api_key: str = Field(
21
+ description="The API key to your Omni instance.",
22
+ examples=['"{{ env.OMNI_API_KEY }}"'],
23
+ repr=False,
24
+ )
25
+ max_retries: int = Field(
26
+ default=5, description="The maximum number of retries to make when rate-limited."
27
+ )
28
+ base_delay: float = Field(
29
+ default=4.0,
30
+ description="The base delay for exponential backoff between retries in seconds.",
31
+ )
32
+
33
+ @property
34
+ def base_api_url(self) -> str:
35
+ return f"{self.base_url.rstrip('/')}/api/v1"
36
+
37
+ def _get_session(self) -> aiohttp.ClientSession:
38
+ """Create configured session with Bearer token authentication."""
39
+ headers = {
40
+ "Accept": "application/json",
41
+ "Content-Type": "application/json",
42
+ "Authorization": f"Bearer {self.api_key}",
43
+ }
44
+ return aiohttp.ClientSession(headers=headers)
45
+
46
+ def _should_retry(self, exc: BaseException) -> bool:
47
+ """Determine if an exception should trigger a retry."""
48
+ if isinstance(exc, ClientResponseError):
49
+ return exc.status == 429 or 500 <= exc.status < 600
50
+ return isinstance(exc, aiohttp.ClientError)
51
+
52
+ def _build_url(self, endpoint: str) -> str:
53
+ return f"{self.base_url.rstrip('/')}/{endpoint.lstrip('/')}"
54
+
55
+ async def make_request(
56
+ self,
57
+ endpoint: str,
58
+ params: Optional[dict[str, Any]] = None,
59
+ headers: Optional[dict[str, str]] = None,
60
+ ) -> dict[str, Any]:
61
+ """Make a GET request to the API with retry logic."""
62
+ url = self._build_url(endpoint)
63
+ if params:
64
+ url = f"{url}?{urllib.parse.urlencode(params)}"
65
+
66
+ async def _make_request():
67
+ async with self._get_session() as session:
68
+ request_headers = headers or {}
69
+ async with session.get(url, headers=request_headers) as response:
70
+ response.raise_for_status()
71
+ return await response.json()
72
+
73
+ return await async_backoff(
74
+ _make_request,
75
+ retry_on=self._should_retry,
76
+ max_retries=self.max_retries,
77
+ delay_generator=exponential_delay_generator(base_delay=self.base_delay),
78
+ )
79
+
80
+ async def _fetch_document_queries(self, document_identifier: str) -> list[OmniQuery]:
81
+ """Fetch all queries for a specific document."""
82
+ endpoint = f"api/v1/documents/{document_identifier}/queries"
83
+ try:
84
+ response = await self.make_request(endpoint)
85
+ return [OmniQuery.from_json(query_data) for query_data in response.get("queries", [])]
86
+ except ClientResponseError as e:
87
+ # When a document has no queries, this will return 404
88
+ if e.status == 404:
89
+ return []
90
+ raise
91
+
92
+ async def _fetch_document_with_queries(self, document_data: dict[str, Any]) -> OmniDocument:
93
+ """Returns an OmniDocument with its queries embedded."""
94
+ queries = await self._fetch_document_queries(document_data["identifier"])
95
+ return OmniDocument.from_json(document_data, queries)
96
+
97
+ async def _fetch_documents(self) -> list[OmniDocument]:
98
+ """Fetch all documents from the Omni API with their queries embedded."""
99
+ base_params = {"pageSize": "100", "include": "_count"}
100
+ documents = []
101
+ next_cursor = None
102
+
103
+ while True:
104
+ params = base_params.copy()
105
+ if next_cursor:
106
+ params["cursor"] = next_cursor
107
+
108
+ response = await self.make_request("api/v1/documents", params)
109
+
110
+ # Fan out the requests to fetch queries for each document in parallel
111
+ coroutines = [
112
+ self._fetch_document_with_queries(doc_data)
113
+ for doc_data in response.get("records", [])
114
+ ]
115
+ documents.extend(await asyncio.gather(*coroutines))
116
+
117
+ next_cursor = response.get("pageInfo", {}).get("nextCursor")
118
+ if not next_cursor:
119
+ break
120
+
121
+ return documents
122
+
123
+ async def _fetch_users(self) -> list[OmniUser]:
124
+ """Fetch all users from the Omni SCIM API."""
125
+ base_params = {"count": "100"}
126
+ users = []
127
+ start_index = 1
128
+
129
+ while True:
130
+ params = base_params.copy()
131
+ params["startIndex"] = str(start_index)
132
+
133
+ response = await self.make_request("api/scim/v2/users", params)
134
+
135
+ user_resources = response.get("Resources", [])
136
+ if not user_resources:
137
+ break
138
+
139
+ users.extend([OmniUser.from_json(user_data) for user_data in user_resources])
140
+
141
+ # Check if we've received fewer users than requested, indicating we're done
142
+ if len(user_resources) < int(base_params["count"]):
143
+ break
144
+
145
+ start_index += len(user_resources)
146
+
147
+ return users
148
+
149
+ async def fetch_omni_state(self) -> OmniWorkspaceData:
150
+ """Fetch all documents and users from the Omni API.
151
+
152
+ This is the main public method for getting complete Omni state.
153
+ """
154
+ # Fetch documents and users concurrently
155
+ documents, users = await asyncio.gather(self._fetch_documents(), self._fetch_users())
156
+ return OmniWorkspaceData(documents=documents, users=users)
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: dagster_omni
3
+ Version: 0.28.5
4
+ Summary: Package for integrating Omni with Dagster.
5
+ Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-omni
6
+ Author: Dagster Labs
7
+ Author-email: hello@dagsterlabs.com
8
+ License: Apache-2.0
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ License-File: LICENSE
16
+ Requires-Dist: dagster==1.12.5
17
+ Requires-Dist: aiohttp
18
+ Requires-Dist: python-dateutil
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: home-page
23
+ Dynamic: license
24
+ Dynamic: license-file
25
+ Dynamic: requires-dist
26
+ Dynamic: summary
@@ -0,0 +1,12 @@
1
+ dagster_omni/__init__.py,sha256=6QUEBSqA3cRAb4kSWqkdvkUiKMbk0NY1YFdJPW0JEkQ,249
2
+ dagster_omni/component.py,sha256=47CRd2190icq6MAynZzXU6893R5EjPmwMfED4W-tk90,7555
3
+ dagster_omni/objects.py,sha256=4cknF4xIljTYYWYCOKe8Tkaled0_Gq9u9g8Ze_mYnyQ,4960
4
+ dagster_omni/py.typed,sha256=mDShSrm8qg9qjacQc2F-rI8ATllqP6EdgHuEYxuCXZ0,7
5
+ dagster_omni/translation.py,sha256=ZESIkyRe9EsPEj7vsyYRe-NsJZaBEaM89bBtlIHOTIw,4820
6
+ dagster_omni/version.py,sha256=SdGElACDuKJX1c_iqPcfu_quaKOShee-DePM8qfbbJU,23
7
+ dagster_omni/workspace.py,sha256=C2fjZIw64TEKWRtpzt6rRm5MSY4RKCXJW22ANJBjY-o,5893
8
+ dagster_omni-0.28.5.dist-info/licenses/LICENSE,sha256=lY5yc1KHX4HoXjlWnIPGcCAsnNney2rb8M8ccT6NzRQ,11347
9
+ dagster_omni-0.28.5.dist-info/METADATA,sha256=uegZrCSnj_hNa1CAq1n9K_jQoWMID4aLRfIQ0EntpPI,862
10
+ dagster_omni-0.28.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ dagster_omni-0.28.5.dist-info/top_level.txt,sha256=FJO_1xyIWRN_nGhCDQPirG5NrEsB-wPR7eY5puEgJes,13
12
+ dagster_omni-0.28.5.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2023 Dagster Labs, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ dagster_omni