Skip to content

Instantly share code, notes, and snippets.

View hrisheekeshr's full-sized avatar
:octocat:
Never argue with the data.

Hrisheekesh R hrisheekeshr

:octocat:
Never argue with the data.
View GitHub Profile
@hrisheekeshr
hrisheekeshr / data.py
Created June 20, 2018 06:25
Dataframe to json
def create_configurations(dataframe_object):
dct = player_config1.to_dict(orient='records')
configurations = {}
for item in dct:
configurations[item['Key']] = item['Value']
return configurations
def calculate_good_bad_average(data):
result = data.groupby(['Competency','Status'])['Status'].count()
keys = result.to_dict().keys()
competency= list()
for item in keys:
a = dict()
a = {
"Competency" : item[0],
item[1].lower() : result[item]
@hrisheekeshr
hrisheekeshr / tensorflow_fundamentals.ipynb
Created December 18, 2018 00:07
Tensorflow Fundamentals
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Paragraph:
Ethers are a class of organic compounds that contain an ether group—an oxygen atom connected to two alkyl or aryl groups. They have the general formula R–O–R′, where R and R′ represent the alkyl or aryl groups. Ethers can again be classified into two varieties: if the alkyl groups are the same on both sides of the oxygen atom, then it is a simple or symmetrical ether, whereas if they are different, the ethers are called mixed or unsymmetrical ethers. A typical example of the first group is the solvent and anesthetic diethyl ether, commonly referred to simply as "ether" (CH3–CH2–O–CH2–CH3). Ethers are common in organic chemistry and even more prevalent in biochemistry, as they are common linkages in carbohydrates and lignin.
Questions:
What is the formula of alkyl group?
What is symmetrical ether ?
Paragraph:
BERT is conceptually simple and empirically powerful. It obtains new state-of-the-art results on eleven natural language processing tasks, including pushing the GLUE benchmark to 80.4% (7.6%
@hrisheekeshr
hrisheekeshr / CORS
Created May 15, 2019 12:22
Add CORS flask
def add_cors_headers(response):
response.headers['Access-Control-Allow-Origin'] = '*'
if request.method == 'OPTIONS':
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT'
headers = request.headers.get('Access-Control-Request-Headers')
if headers:
response.headers['Access-Control-Allow-Headers'] = headers
return response
app.after_request(add_cors_headers)
@hrisheekeshr
hrisheekeshr / substring_cost.py
Created June 14, 2019 18:06
Substing Cost Optimimisation
cost = 0
initial_string = ""
initial_list = []
def get_all_substrings(input_string):
length = len(input_string)
return [input_string[i:j+1] for i in range(length) for j in range(i,length)]
#This takes the input indefenitely
while True:
{
"questions": ["I need a developer license for a test instance. How do I get one?"],
"top_k_reader": 5,
"top_k_retriever": 5
}
import tensorflow as tf
import tensorflow_hub as hub
print("TF version:", tf.__version__)
print("Hub version:", hub.__version__)
print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")
model_name = "inception_v3"
model_handle_map = {

You can configure Alembic to run migrations on two separate PostgreSQL databases in a single alembic upgrade head command by modifying the env.py script. Here's the approach:

  1. Modify env.py to Manage Multiple Engines:

    • Create two separate SQLAlchemy engines (one for each database) inside the env.py script.
    • Ensure that migrations are applied to both databases.
  2. Use run_migrations_online for Both Databases:

    • Instead of a single engine, define and use two engines.
    • Use context.run_migrations() for each engine.

To follow best practices for running Alembic migrations on two separate PostgreSQL databases while using SQLModel, you should:

  1. Assign Models to Specific Databases: Define separate metadata objects to distinguish models belonging to each database.
  2. Use Separate Migration Folders: Store migration scripts in distinct directories to avoid conflicts and keep each database's schema changes independent.
  3. Modify env.py to Handle Multiple Databases: Configure Alembic to run migrations sequentially for both databases by looping through their configurations and applying changes to the correct metadata.
  4. Ensure Autogeneration Works Properly: Implement logic in env.py to apply --autogenerate migrations to the correct metadata.
  5. Use Async and Sync Engines Correctly: Handle async database connections properly in the Alembic migration flow.

I'll prepare a detailed setup with env.py modifications, migration folder structures, and best practices to ensure Alembic knows which models