Skip to content

Commit

Permalink
Merge pull request #170 from LSSTDESC/u/stuart/link_schemas
Browse files Browse the repository at this point in the history
Link schemas
  • Loading branch information
stuartmcalpine authored Jan 16, 2025
2 parents 18961ab + 463ee9e commit 84272e4
Show file tree
Hide file tree
Showing 27 changed files with 647 additions and 450 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## Version 1.1.0

When connection to the database, both schemas are connected to and both schemas
are reflected. This means that for all queries both schemas are queried by
default and their results combined.

For registering and modifying there is still only a single "active" schema per
`DataRegistry()` (i.e., `DbConnection()`) instance. If the database was
connected to with `production_mode=False` (the default), registered datasets
will go into the working schema. If `production_mode=True` registered datasets
will go into the production schema. The same logic is true for modifying
registry entries.

## Version 1.0.5

Update delete functionality
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_registry_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _BuildTable(schema, table_name, has_production, production):
# Loop over each schema
for schema in schema_list:
# Connect to database to find out what the backend is
db_connection = DbConnection(args.config, schema)
db_connection = DbConnection(args.config, schema, creation_mode=True)
print(f"Database dialect is '{db_connection.dialect}'")

if db_connection.dialect == "sqlite":
Expand Down
11 changes: 7 additions & 4 deletions src/dataregistry/DataRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(
root_dir=None,
verbose=False,
site=None,
production_mode=False,
):
"""
Primary data registry wrapper class.
Expand Down Expand Up @@ -54,18 +55,20 @@ def __init__(
Can be used instead of `root_dir`. Some predefined "sites" are
built in, such as "nersc", which will set the `root_dir` to the
data registry's default data location at NERSC.
production_mode : bool, optional
True to register/modify production schema entries
"""

# Establish connection to database
self.db_connection = DbConnection(config_file, schema=schema,
verbose=verbose)
self.db_connection = DbConnection(
config_file, schema=schema, verbose=verbose, production_mode=production_mode
)

# Work out the location of the root directory
self.root_dir = self._get_root_dir(root_dir, site)

# Create registrar object
self.Registrar = Registrar(self.db_connection, self.root_dir,
owner, owner_type)
self.Registrar = Registrar(self.db_connection, self.root_dir, owner, owner_type)

# Create query object
self.Query = Query(self.db_connection, self.root_dir)
Expand Down
2 changes: 1 addition & 1 deletion src/dataregistry/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.5"
__version__ = "1.1.0"
Loading

0 comments on commit 84272e4

Please sign in to comment.