aic-utils 0.2__tar.gz → 0.22__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.22
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,37 @@
1
+ import pandas as pd
2
+
3
+ def get_dataset_ids(dataset, table, aliases, QA):
4
+ """
5
+ Fetch dataset IDs for given aliases from a mapping table.
6
+
7
+ Parameters:
8
+ - dataset (str): The dataset name.
9
+ - table (str): The table name.
10
+ - aliases (str or list): A single alias or a list of aliases.
11
+ - QA (bool): Flag to determine whether to fetch QA or production dataset IDs.
12
+
13
+ Returns:
14
+ - list: A list of dataset IDs corresponding to the provided aliases.
15
+ """
16
+
17
+ # Load the mapping DataFrame
18
+ df = pyspark_utils.get_pandas_from_aic_table(dataset, table)
19
+
20
+ # Determine the target column based on the QA flag
21
+ target_col = 'qa_dataset' if QA else 'prod_dataset'
22
+
23
+ # Handle both single alias (string) and multiple aliases (list)
24
+ if isinstance(aliases, str):
25
+ aliases = [aliases]
26
+
27
+ # List to store the results
28
+ results = []
29
+
30
+ for alias in aliases:
31
+ row = df[df['alias'] == alias]
32
+ if not row.empty:
33
+ results.append(row.iloc[0][target_col])
34
+ else:
35
+ results.append(None) # or raise ValueError(f"Alias '{alias}' not found in mapping table")
36
+
37
+ return results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aic_utils
3
- Version: 0.2
3
+ Version: 0.22
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.22',
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