Skip to content

Commit

Permalink
make release-tag: Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
amontanez24 committed Oct 10, 2024
2 parents 5c71e29 + 4b6f255 commit ce8867c
Show file tree
Hide file tree
Showing 15 changed files with 348 additions and 172 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/dtypes_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
jobs:
run_dtypes_benchmark:
runs-on: ubuntu-latest
timeout-minutes: 20

strategy:
matrix:
Expand Down Expand Up @@ -39,6 +40,8 @@ jobs:
run: |
invoke benchmark-dtypes
continue-on-error: true

# Upload the json files as artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_code_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
commit-message: Update static code analysis
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
Expand Down
17 changes: 16 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Release Notes

### v1.17.0 - 2024-10-02
### v1.17.1 - 2024-10-10

### Bugs Fixed

* Extraneous metadata warning is printed when customizing HMA Synthesizer - Issue [#2250](https://github.com/sdv-dev/SDV/issues/2250) by @pvk-developer

### Internal

* `ValueError` raised when adding columns to a new `Metadata` instance - Issue [#2252](https://github.com/sdv-dev/SDV/issues/2252) by @pvk-developer
* Enhance Benchmark Report Generation - Issue [#2235](https://github.com/sdv-dev/SDV/issues/2235) by @pvk-developer

### Maintenance

* Use PyDrive2 instead of PyDrive - Issue [#2238](https://github.com/sdv-dev/SDV/issues/2238) by @pvk-developer

## v1.17.0 - 2024-10-02

This release consolidates the `SingleTableMetadata` and `MultiTableMetadata` classes into one new class simply called `Metadata`. The old classes are now deprecated. The new class has the same structure as the `MultiTableMetadata` class, except it will work with single table synthesizers.

Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ test = [
'rundoc>=0.4.3,<0.5',
'pytest-runner >= 2.11.1',
'tomli>=2.0.0,<3',
'pydrive',
'google-api-python-client',
'google-auth',
'google-auth-oauthlib',
'requests',
'pyarrow',
'gitpython',
'slack-sdk>=3.23,<4.0',
Expand Down Expand Up @@ -136,7 +139,7 @@ namespaces = false
version = {attr = 'sdv.__version__'}

[tool.bumpversion]
current_version = "1.17.0"
current_version = "1.17.1.dev1"
parse = '(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<candidate>\d+))?'
serialize = [
'{major}.{minor}.{patch}.{release}{candidate}',
Expand Down
2 changes: 1 addition & 1 deletion sdv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

__author__ = 'DataCebo, Inc.'
__email__ = 'info@sdv.dev'
__version__ = '1.17.0'
__version__ = '1.17.1.dev1'


import sys
Expand Down
18 changes: 18 additions & 0 deletions sdv/metadata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def _set_metadata_dict(self, metadata, single_table_name=None):
'No table name was provided to metadata containing only one table. '
f'Assigning name: {single_table_name}'
)

self.tables[single_table_name] = SingleTableMetadata.load_from_dict(metadata)

def _get_single_table_name(self):
Expand Down Expand Up @@ -162,6 +163,8 @@ def _convert_to_single_table(self):
return next(iter(self.tables.values()), SingleTableMetadata())

def _handle_table_name(self, table_name):
if len(self.tables) == 0:
raise ValueError('Metadata does not contain any tables. No columns can be added.')
if table_name is None:
if len(self.tables) == 1:
table_name = next(iter(self.tables))
Expand Down Expand Up @@ -270,3 +273,18 @@ def add_alternate_keys(self, column_names, table_name=None):
"""Add alternate keys to a table."""
table_name = self._handle_table_name(table_name)
super().add_alternate_keys(table_name, column_names)

def get_table_metadata(self, table_name=None):
"""Return the metadata for a table.
Args:
table_name (str):
The name of the table to get the metadata for.
Returns:
Metadata:
The metadata for the given table.
"""
table_name = self._handle_table_name(table_name)
table_metadata = super().get_table_metadata(table_name)
return Metadata.load_from_dict(table_metadata.to_dict(), single_table_name=table_name)
3 changes: 2 additions & 1 deletion sdv/multi_table/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ def set_table_parameters(self, table_name, table_parameters):
A dictionary with the parameters as keys and the values to be used to instantiate
the table's synthesizer.
"""
table_metadata = self.metadata.get_table_metadata(table_name)
self._table_synthesizers[table_name] = self._synthesizer(
metadata=self.metadata.tables[table_name], **table_parameters
metadata=table_metadata, **table_parameters
)
self._table_parameters[table_name].update(deepcopy(table_parameters))

Expand Down
12 changes: 5 additions & 7 deletions sdv/multi_table/hma.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class HMASynthesizer(BaseHierarchicalSampler, BaseMultiTableSynthesizer):
"""Hierarchical Modeling Algorithm One.
Args:
metadata (sdv.metadata.multi_table.MultiTableMetadata):
Multi table metadata representing the data tables that this synthesizer will be used
for.
metadata (sdv.metadata.Metadata):
Metadata representing the data tables that this synthesizer will be used for.
locales (list or str):
The default locale(s) to use for AnonymizedFaker transformers.
Defaults to ``['en_US']``.
Expand All @@ -47,8 +46,8 @@ def _get_num_data_columns(metadata):
"""Get the number of data columns, ie colums that are not id, for each table.
Args:
metadata (MultiTableMetadata):
Metadata of the datasets.
metadata (sdv.metadata.Metadata):
Metadata representing the data tables that this synthesizer will be used for.
"""
columns_per_table = {}
for table_name, table in metadata.tables.items():
Expand Down Expand Up @@ -552,8 +551,7 @@ def _recreate_child_synthesizer(self, child_name, parent_name, parent_row):
if parent_row is not None:
parameters = self._extract_parameters(parent_row, child_name, foreign_key)
default_parameters = getattr(self, '_default_parameters', {}).get(child_name, {})

table_meta = self.metadata.tables[child_name]
table_meta = self.metadata.get_table_metadata(child_name)
synthesizer = self._synthesizer(table_meta, **self._table_parameters[child_name])
synthesizer._set_parameters(parameters, default_parameters)
else:
Expand Down
9 changes: 3 additions & 6 deletions sdv/sampling/hierarchical_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,10 @@ def _add_child_rows(self, child_name, parent_name, parent_row, sampled_data, num
foreign_key = self.metadata._get_foreign_keys(parent_name, child_name)[0]
if num_rows is None:
num_rows = parent_row[f'__{child_name}__{foreign_key}__num_rows']
with warnings.catch_warnings():
warnings.filterwarnings('ignore', message=".*The 'SingleTableMetadata' is deprecated.*")
child_synthesizer = self._recreate_child_synthesizer(
child_name, parent_name, parent_row
)
sampled_rows = self._sample_rows(child_synthesizer, num_rows)

child_synthesizer = self._recreate_child_synthesizer(child_name, parent_name, parent_row)

sampled_rows = self._sample_rows(child_synthesizer, num_rows)
if len(sampled_rows):
parent_key = self.metadata.tables[parent_name].primary_key
if foreign_key in sampled_rows:
Expand Down
4 changes: 2 additions & 2 deletions static_code_analysis.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Run started:2024-09-26 20:22:23.878117
Run started:2024-10-02 16:26:36.866545

Test results:
>> Issue: [B105:hardcoded_password_string] Possible hardcoded password: '# Release Notes
Expand Down Expand Up @@ -69,7 +69,7 @@ Test results:
--------------------------------------------------

Code scanned:
Total lines of code: 12468
Total lines of code: 12759
Total lines skipped (#nosec): 0
Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Expand Down
Loading

0 comments on commit ce8867c

Please sign in to comment.