Skip to content

Commit

Permalink
Add get_schema_id to Schema class
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmartradio committed Aug 21, 2024
1 parent fac0a32 commit 0ea4f4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion python/lsst/alert/packet/bin/syncAllSchemasToRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import argparse
import json
import re
import fastavro
import requests

Expand Down
13 changes: 12 additions & 1 deletion python/lsst/alert/packet/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

import io
import tempfile
import re
import fastavro
from importlib import resources
from pathlib import PurePath

from lsst.resources import ResourcePath

import fastavro

__all__ = ["get_schema_root", "get_latest_schema_version", "get_schema_path",
"Schema", "get_path_to_latest_schema", "get_schema_root_uri",
Expand Down Expand Up @@ -428,3 +430,12 @@ def from_file(cls, filename=None):
if schema['name'] == root_name)

return cls(schema_definition)

def get_schema_id(self):
"""Retrieve the schema id used in the schema registry.
"""
numbers = re.findall(r'\d+', self.definition['name'])
numbers[1] = str(numbers[1]).zfill(2)
schema_id = int(''.join(numbers))

return schema_id
2 changes: 0 additions & 2 deletions python/lsst/alert/packet/schemaRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
"""Provide a lookup table for alert schemas.
"""

import json
import os
import re
import zlib

__all__ = ["SchemaRegistry"]

Expand Down

0 comments on commit 0ea4f4e

Please sign in to comment.