-
Notifications
You must be signed in to change notification settings - Fork 14
Use timestamp in place of version for query table for expired tables #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
483f0c9
2511fac
73658b1
8bc987a
dff5d6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,7 +53,7 @@ | |||||||||||||
| ) | ||||||||||||||
| else: | ||||||||||||||
| raise ValueError( | ||||||||||||||
| f'Unknown response type: {response.headers.get("Content-Type")}' | ||||||||||||||
| f"Unknown response type: {response.headers.get('Content-Type')}" | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
@@ -228,6 +228,12 @@ | |||||||||||||
| self._tables = None | ||||||||||||||
| self._views = None | ||||||||||||||
|
|
||||||||||||||
| @property | ||||||||||||||
| @cached(cache=TTLCache(maxsize=1, ttl=60 * 60 * 1)) | ||||||||||||||
| def available_versions(self) -> list[int]: | ||||||||||||||
| """Get the available versions for this materialization client.""" | ||||||||||||||
| return sorted(self.get_versions(expired=False)) | ||||||||||||||
|
|
||||||||||||||
| @property | ||||||||||||||
| def datastack_name(self): | ||||||||||||||
| """The name of the datastack.""" | ||||||||||||||
|
|
@@ -361,6 +367,10 @@ | |||||||||||||
| datastack_name = self.datastack_name | ||||||||||||||
| if version is None: | ||||||||||||||
| version = self.version | ||||||||||||||
| if version not in self.available_versions: | ||||||||||||||
| raise ValueError( | ||||||||||||||
| f"Annotation count must use a materialized version ({self.available_versions})." | ||||||||||||||
| ) | ||||||||||||||
| endpoint_mapping = self.default_url_mapping | ||||||||||||||
| endpoint_mapping["datastack_name"] = datastack_name | ||||||||||||||
| endpoint_mapping["table_name"] = table_name | ||||||||||||||
|
|
@@ -406,6 +416,7 @@ | |||||||||||||
| d["expires_on"] = convert_timestamp(d["expires_on"]) | ||||||||||||||
| return d | ||||||||||||||
|
|
||||||||||||||
| @cached(cache=TTLCache(maxsize=50, ttl=60 * 60 * 24)) | ||||||||||||||
| def get_timestamp( | ||||||||||||||
| self, version: Optional[int] = None, datastack_name: str = None | ||||||||||||||
| ) -> datetime: | ||||||||||||||
|
|
@@ -741,6 +752,14 @@ | |||||||||||||
|
|
||||||||||||||
| if desired_resolution is None: | ||||||||||||||
| desired_resolution = self.desired_resolution | ||||||||||||||
| if ( | ||||||||||||||
| materialization_version not in self.available_versions | ||||||||||||||
| and materialization_version is not None | ||||||||||||||
| ): | ||||||||||||||
| timestamp = self.get_timestamp( | ||||||||||||||
| version=materialization_version, datastack_name=datastack_name | ||||||||||||||
| ) | ||||||||||||||
| materialization_version = None | ||||||||||||||
| if timestamp is not None: | ||||||||||||||
| if materialization_version is not None: | ||||||||||||||
| raise ValueError("cannot specify timestamp and materialization version") | ||||||||||||||
|
|
@@ -975,6 +994,10 @@ | |||||||||||||
|
|
||||||||||||||
| if materialization_version is None: | ||||||||||||||
| materialization_version = self.version | ||||||||||||||
| if materialization_version not in self.available_versions: | ||||||||||||||
|
||||||||||||||
| raise ValueError( | ||||||||||||||
| f"Cannot use `join_query` for a non-materialized version. Please use a materialized version ({self.available_versions}) or live_live_query." | ||||||||||||||
| ) | ||||||||||||||
| if datastack_name is None: | ||||||||||||||
| datastack_name = self.datastack_name | ||||||||||||||
| if desired_resolution is None: | ||||||||||||||
|
|
@@ -1178,7 +1201,7 @@ | |||||||||||||
| all_svid_lengths.append(n_svids) | ||||||||||||||
| logger.info(f"{sv_col} has {n_svids} to update") | ||||||||||||||
| all_svids = np.append(all_svids, svids[~is_latest_root]) | ||||||||||||||
| logger.info(f"num zero svids: {np.sum(all_svids==0)}") | ||||||||||||||
| logger.info(f"num zero svids: {np.sum(all_svids == 0)}") | ||||||||||||||
| logger.info(f"all_svids dtype {all_svids.dtype}") | ||||||||||||||
| logger.info(f"all_svid_lengths {all_svid_lengths}") | ||||||||||||||
| with MyTimeIt("get_roots"): | ||||||||||||||
|
|
@@ -2225,6 +2248,11 @@ | |||||||||||||
| datastack_name = self.datastack_name | ||||||||||||||
| if version is None: | ||||||||||||||
| version = self.version | ||||||||||||||
| if version not in self.available_versions: | ||||||||||||||
| raise ValueError( | ||||||||||||||
| f"Materialization version must not be expired for views. " | ||||||||||||||
| f"Available versions: {self.available_versions}" | ||||||||||||||
| ) | ||||||||||||||
|
||||||||||||||
| if version not in self.available_versions: | |
| raise ValueError( | |
| f"Materialization version must not be expired for views. " | |
| f"Available versions: {self.available_versions}" | |
| ) | |
| self.validate_version(version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting version validation and fallback logic into a shared helper to reduce duplication and maintain consistent behavior across query methods.