Skip to content

Commit

Permalink
Merge pull request #124 from DocShow-AI/create-new-data-profile-bug-fix
Browse files Browse the repository at this point in the history
bug fix create data profile
  • Loading branch information
liberty-rising authored Dec 19, 2023
2 parents e59a958 + a1f591b commit 9927be1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions backend/databases/data_profile_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ def create_dataprofile(self, data_profile_data: DataProfileCreateRequest):
"""Create a new DataProfile."""
new_data_profile = DataProfile(
name=data_profile_data.name,
file_type=data_profile_data.file_type, # Assuming it's included in the request
organization_id=data_profile_data.organization_id, # Assuming it's included in the request
file_type=data_profile_data.file_type,
organization_id=data_profile_data.organization_id,
description=data_profile_data.description,
)
self.session.add(new_data_profile)
self.session.commit()
return new_data_profile.to_dict()
return new_data_profile

def get_dataprofile_by_id(self, data_profile_id: int):
"""Retrieve a DataProfile by its ID."""
Expand Down
4 changes: 3 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ python-jose-cryptodome==1.3.2
passlib==1.7.4
bcrypt==3.2.0
alembic==1.12.1
pydantic[email]==2.4.2
pydantic[email]==2.4.2
pytest==6.2.5
pytest-asyncio==0.15.1
14 changes: 11 additions & 3 deletions backend/routes/data_profile_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ async def save_data_profiles(
with DatabaseManager() as session:
data_profile_manager = DataProfileManager(session)
if data_profile_manager.get_dataprofile_by_name(request.name):
raise HTTPException(status_code=400, detail="Data Profile alredy exists")
raise HTTPException(status_code=400, detail="Data Profile already exists")

new_data_profile = DataProfile(name=request.name)
new_data_profile = DataProfile(
name=request.name,
description=request.description,
)
created_data_profile = data_profile_manager.create_dataprofile(new_data_profile)
response = DataProfileCreateResponse(created_data_profile.name)

# Make sure to pass the fields as keyword arguments
response = DataProfileCreateResponse(
name=created_data_profile.name,
description=created_data_profile.description,
)
return response


Expand Down

0 comments on commit 9927be1

Please sign in to comment.