-
Notifications
You must be signed in to change notification settings - Fork 0
/
try_it_out.py
81 lines (60 loc) · 2.35 KB
/
try_it_out.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# %%
import os
import sys
from dotenv import load_dotenv
import logging
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), '.')))
from lib.AirtablePipelineConfigs import PipelineConfig, AirtableConfig, DatastoreConfig, UpdateType
from lib.AirtableToDatastore import AirtableToDatastore
from lib.AirtableToDatastoreBuilder import AirtableToDatastoreBuilder
from lib.Secrets import Secrets
from google.cloud import firestore
# %%
_= Secrets.get_api_key('AIRTABLE_API_KEY')
# %%
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
# %%
api_key = os.getenv('AIRTABLE_API_KEY')
base_id = os.getenv('AIRTABLE_BASE_ID')
project_id = os.getenv('GOOGLE_CLOUD_PROJECT')
database_id = os.getenv('FS_DATABASE_ID')
datastore_collection = os.getenv('FS_CONFIGS')
# %% [markdown]
# ## process hiring strategies
# %%
source_table = os.getenv('AT_STRATEGY_SPEC_TABLE_NAME')
source_view = os.getenv('AT_STRATEGY_SPEC_VIEW_NAME')
primary_key = os.getenv('AT_STRATEGY_SPEC_PK')
update_type = UpdateType.UPSERT_TABLE_CHECKSUM
# Create configuration
airtable_config = AirtableConfig(base_id=base_id, table_name=source_table, view_name=source_view, api_key=api_key)
datastore_config = DatastoreConfig(project_id=project_id, database_id=database_id, kind=datastore_collection)
pipeline_config = PipelineConfig(
airtable=airtable_config,
datastore=datastore_config,
primary_key=primary_key,
update_type=update_type,
)
# Create and run the pipeline
pipeline = AirtableToDatastore(pipeline_config)
pipeline.run_pipeline()
# %% [markdown]
# ## process candidate evaluation rules -- with builder for more extensive checks/setup
# %%
source_table = os.getenv('AT_CANDIDATE_EVAL_TABLE_NAME')
source_view = os.getenv('AT_CANDIDATE_EVAL_VIEW_NAME')
primary_key = os.getenv('AT_CANDIDATE_EVAL_PK')
update_type = UpdateType.UPSERT_TABLE_CHECKSUM
pipeline_config = (AirtableToDatastoreBuilder()
.with_airtable_config(base_id=base_id, table_name=source_table, view_name=source_view, api_key=api_key)
.with_datastore_config(project_id=project_id, database_id=database_id, kind=datastore_collection)
.with_primary_key(primary_key)
.with_update_type(update_type)
.build())
# Create and run the pipeline
pipeline = AirtableToDatastore(pipeline_config)
pipeline.run_pipeline()
# %% [markdown]
#
# %%