aic-utils 0.2__tar.gz → 0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aic_utils
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: A utility package for dataset ID retrieval
5
5
  Home-page: https://github.com/dylandoyle11/aic_utils
6
6
  Author: Dylan D
@@ -11,4 +11,4 @@ Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: pandas
13
13
 
14
- TEST
14
+ FUNCTIONS FOR AIC
@@ -0,0 +1 @@
1
+ FUNCTIONS FOR AIC
@@ -0,0 +1,4 @@
1
+ # __init__.py
2
+
3
+ from .aic_utils import get_dataset_ids
4
+
@@ -0,0 +1,33 @@
1
+ import pandas as pd
2
+ from google.cloud import bigquery
3
+
4
+ def get_dataset_ids(aliases, QA, dataset=None, table=None):
5
+ # Initialize BigQuery client
6
+ client = bigquery.Client(project='aic-production-core')
7
+ dataset = '3349c7ea_09a2_461d_87f5_312a5401c51a'
8
+ table = 'LKP_QA_TABLE_MAPPING'
9
+
10
+ # Query to read the table
11
+ query = f"SELECT * FROM `{dataset}.{table}`"
12
+
13
+ # Load the table into a DataFrame
14
+ df = client.query(query).to_dataframe()
15
+
16
+ # Determine the target column based on the QA flag
17
+ target_col = 'qa_dataset' if QA else 'prod_dataset'
18
+
19
+ # Handle both single alias (string) and multiple aliases (list)
20
+ if isinstance(aliases, str):
21
+ aliases = [aliases]
22
+
23
+ # List to store the results
24
+ results = []
25
+
26
+ for alias in aliases:
27
+ row = df[df['alias'] == alias]
28
+ if not row.empty:
29
+ results.append(row.iloc[0][target_col])
30
+ else:
31
+ results.append(None) # or raise ValueError(f"Alias '{alias}' not found in mapping table")
32
+
33
+ return *results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aic_utils
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: A utility package for dataset ID retrieval
5
5
  Home-page: https://github.com/dylandoyle11/aic_utils
6
6
  Author: Dylan D
@@ -11,4 +11,4 @@ Classifier: Operating System :: OS Independent
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: pandas
13
13
 
14
- TEST
14
+ FUNCTIONS FOR AIC
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
4
4
 
5
5
  setup(
6
6
  name='aic_utils',
7
- version='0.2',
7
+ version='0.3',
8
8
  packages=find_packages(),
9
9
  install_requires=[
10
10
  'pandas',
aic_utils-0.2/README.md DELETED
@@ -1 +0,0 @@
1
- TEST
@@ -1,4 +0,0 @@
1
- # __init__.py
2
-
3
- from .aic_utils import get_dataset_id
4
-
@@ -1,22 +0,0 @@
1
- # aic_utils.py
2
-
3
- import pandas as pd
4
-
5
- def get_dataset_id(alias, QA):
6
- # MAP WRITES TO QA OR PROD TABLES
7
- df = pyspark_utils.get_pandas_from_aic_table('Silver',
8
- 'LKP_QA_TABLE_MAPPING')
9
- row = df[df['alias'] == alias]
10
-
11
- # Choose the appropriate column based on QA flag
12
- if QA:
13
- target_col = 'qa_dataset'
14
- else:
15
- target_col = 'prod_dataset'
16
-
17
- # Return the dataset ID
18
- if not row.empty:
19
- return row.iloc[0][target_col]
20
- else:
21
- raise ValueError("Alias not found in mapping table")
22
-
File without changes