Skip to content
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

Link schemas #170

Merged
merged 16 commits into from
Jan 16, 2025
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
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
Loading