Skip to content

Commit dc58f14

Browse files
jirhikeractions-user
authored andcommitted
Formatting changes
1 parent 910dc3c commit dc58f14

12 files changed

Lines changed: 73 additions & 42 deletions

File tree

api/asset.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
router = APIRouter(prefix="/asset", tags=["asset"])
2424

25+
2526
@router.get("/{asset_id}")
26-
async def get_asset(asset_id: int,
27-
database_session: Session = Depends(get_db_session)
28-
):
27+
async def get_asset(asset_id: int, database_session: Session = Depends(get_db_session)):
2928
"""
3029
Retrieve an asset by its ID.
3130
"""
@@ -34,9 +33,9 @@ async def get_asset(asset_id: int,
3433

3534

3635
@router.post("/", status_code=201)
37-
async def add_asset(file: UploadFile,
38-
database_session: Session = Depends(get_db_session)
39-
):
36+
async def add_asset(
37+
file: UploadFile, database_session: Session = Depends(get_db_session)
38+
):
4039
"""
4140
Add a new asset.
4241
"""
@@ -46,10 +45,12 @@ async def add_asset(file: UploadFile,
4645

4746
content = file.file.read()
4847
asset.content = content
49-
if file.content_type.startswith('image/'):
48+
if file.content_type.startswith("image/"):
5049
asset.photo = content
5150

5251
database_session.add(asset)
5352
database_session.commit()
5453
return asset
54+
55+
5556
# ============= EOF =============================================

api/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,9 @@ async def get_group_location_by_id(
528528
"""
529529
Retrieve a group location by ID from the database.
530530
"""
531-
group_location = simple_get_by_id(session, GroupLocationAssociation, group_location_id)
531+
group_location = simple_get_by_id(
532+
session, GroupLocationAssociation, group_location_id
533+
)
532534
if not group_location:
533535
return {"message": "Group location not found"}
534536
return group_location

db/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,14 @@ def created_at(self):
109109

110110

111111
def pascal_to_snake(name):
112-
return re.sub(r'(?<!^)(?=[A-Z])', '_', name).lower()
112+
return re.sub(r"(?<!^)(?=[A-Z])", "_", name).lower()
113113

114114

115115
class AutoBaseMixin(AuditMixin):
116116
@declared_attr
117117
def __tablename__(self):
118118
return pascal_to_snake(self.__name__)
119119

120-
121120
@declared_attr
122121
def id(self):
123122
return Column(Integer, primary_key=True, autoincrement=True)

db/asset.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ class Asset(Base, AutoBaseMixin):
3232

3333
class AssetLocationAssociation(Base, AutoBaseMixin):
3434

35-
36-
asset_id = Column(Integer, ForeignKey("asset.id", ondelete='CASCADE'), nullable=False)
37-
location_id = Column(Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False)
35+
asset_id = Column(
36+
Integer, ForeignKey("asset.id", ondelete="CASCADE"), nullable=False
37+
)
38+
location_id = Column(
39+
Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False
40+
)
3841

3942
location = relationship("SampleLocation", back_populates="asset_associations")
4043

4144
# publication = relationship("Publication", back_populates="author_associations")
4245
# author = relationship("Author", back_populates="publication_associations")
4346

47+
4448
# ============= EOF =============================================

db/base.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ class SampleLocation(Base, AutoBaseMixin):
4040
Geometry(geometry_type="POINT", srid=4326, spatial_index=True)
4141
)
4242

43-
owner_id = Column(Integer, ForeignKey("owner.id", ondelete='CASCADE'), nullable=True)
43+
owner_id = Column(
44+
Integer, ForeignKey("owner.id", ondelete="CASCADE"), nullable=True
45+
)
4446

45-
asset_associations = relationship("AssetLocationAssociation",
46-
back_populates="location",
47-
cascade="all, delete-orphan"
48-
)
47+
asset_associations = relationship(
48+
"AssetLocationAssociation",
49+
back_populates="location",
50+
cascade="all, delete-orphan",
51+
)
4952
assets = association_proxy("asset_associations", "asset")
5053

5154

@@ -85,7 +88,9 @@ class Contact(Base, AutoBaseMixin):
8588

8689

8790
class Well(Base, AutoBaseMixin):
88-
location_id = Column(Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False)
91+
location_id = Column(
92+
Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False
93+
)
8994

9095
ose_pod_id = Column(String(50), nullable=True)
9196
api_id = Column(String(50), nullable=True, default="") # API well number
@@ -126,7 +131,7 @@ class Well(Base, AutoBaseMixin):
126131

127132

128133
class WellScreen(Base, AutoBaseMixin):
129-
well_id = Column(Integer, ForeignKey("well.id", ondelete='CASCADE'), nullable=False)
134+
well_id = Column(Integer, ForeignKey("well.id", ondelete="CASCADE"), nullable=False)
130135
screen_depth_top = Column(
131136
Float, nullable=False, info={"unit": "feet below ground surface"}
132137
)
@@ -149,14 +154,18 @@ class Equipment(Base, AutoBaseMixin):
149154
date_removed = Column(DateTime)
150155
recording_interval = Column(Integer)
151156
equipment_notes = Column(String(50))
152-
location_id = Column(Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False)
157+
location_id = Column(
158+
Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False
159+
)
153160

154161
location = relationship("SampleLocation")
155162

156163

157164
class Spring(Base, AutoBaseMixin):
158165
description = Column(String(255), nullable=True)
159-
location_id = Column(Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False)
166+
location_id = Column(
167+
Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False
168+
)
160169

161170
# Define a relationship to samplelocations if needed
162171
location = relationship("SampleLocation")
@@ -171,8 +180,12 @@ class Group(Base, AutoBaseMixin):
171180

172181

173182
class GroupLocationAssociation(Base, AutoBaseMixin):
174-
group_id = Column(Integer, ForeignKey("group.id", ondelete='CASCADE'), nullable=False)
175-
location_id = Column(Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False)
183+
group_id = Column(
184+
Integer, ForeignKey("group.id", ondelete="CASCADE"), nullable=False
185+
)
186+
location_id = Column(
187+
Integer, ForeignKey("sample_location.id", ondelete="CASCADE"), nullable=False
188+
)
176189

177190
# group = relationship("Group")
178191
# location = relationship("SampleLocation")

db/chemistry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class WaterChemistryAnalysisSet(Base, AutoBaseMixin):
5252

5353
__tablename__ = "water_chemistry_analysis_set"
5454

55-
well_id = mapped_column(Integer, ForeignKey("well.id" , ondelete='CASCADE'))
55+
well_id = mapped_column(Integer, ForeignKey("well.id", ondelete="CASCADE"))
5656
note = mapped_column(String(255), nullable=True)
5757

5858
collection_timestamp = mapped_column(DateTime, nullable=False)

db/collabnet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class CollaborativeNetworkWell(Base, AutoBaseMixin):
2323
""" """
2424

2525
actively_monitored = mapped_column(Boolean, default=False, nullable=False)
26-
well_id = mapped_column(Integer, ForeignKey("well.id", ondelete='CASCADE'), nullable=False)
26+
well_id = mapped_column(
27+
Integer, ForeignKey("well.id", ondelete="CASCADE"), nullable=False
28+
)
2729

2830
well = relationship("Well")
2931

db/geothermal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GeothermalTemperatureProfile(Base, AutoBaseMixin):
2323
""" """
2424

2525
__tablename__ = "geothermal_temperature_profile"
26-
well_id = mapped_column(Integer, ForeignKey("well.id", ondelete='CASCADE'))
26+
well_id = mapped_column(Integer, ForeignKey("well.id", ondelete="CASCADE"))
2727

2828
def __repr__(self):
2929
return f"<GeothermalTemperatureProfile(well_id={self.well_id})>"
@@ -33,7 +33,7 @@ class GeothermalSampleSet(Base, AutoBaseMixin):
3333

3434
__tablename__ = "geothermal_sample_set"
3535

36-
well_id = mapped_column(Integer, ForeignKey("well.id", ondelete='CASCADE'))
36+
well_id = mapped_column(Integer, ForeignKey("well.id", ondelete="CASCADE"))
3737

3838
name = mapped_column(String(128))
3939
klass = mapped_column(String(24))

db/lexicon.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ class TermCategoryAssociation(Base, AutoBaseMixin):
6565
__tablename__ = "lexicon_term_category_association"
6666

6767
lexicon_term = mapped_column(
68-
String(100), ForeignKey("lexicon_term.term", ondelete='CASCADE'), nullable=False
68+
String(100), ForeignKey("lexicon_term.term", ondelete="CASCADE"), nullable=False
6969
)
7070
category_name = mapped_column(
71-
String(255), ForeignKey("lexicon_category.name", ondelete='CASCADE'), nullable=False
71+
String(255),
72+
ForeignKey("lexicon_category.name", ondelete="CASCADE"),
73+
nullable=False,
7274
)
7375

7476
term = relationship("Lexicon")

main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,14 @@
5252

5353
# setup depo
5454
from depot.manager import DepotManager
55-
storage_path = os.getenv("DEPOT_STORAGE_PATH", "./tests/uploads")
56-
DepotManager.configure('default', {'depot.storage_path': storage_path,})
5755

56+
storage_path = os.getenv("DEPOT_STORAGE_PATH", "./tests/uploads")
57+
DepotManager.configure(
58+
"default",
59+
{
60+
"depot.storage_path": storage_path,
61+
},
62+
)
5863

5964

6065
if __name__ == "__main__":

0 commit comments

Comments
 (0)