Skip to content

Commit

Permalink
Merge pull request #93 from ricardogsilva/91-add-pre-commit
Browse files Browse the repository at this point in the history
Add pre-commit
  • Loading branch information
francbartoli authored Jun 3, 2024
2 parents 0bedcbd + eaecdb6 commit 165ffaa
Show file tree
Hide file tree
Showing 54 changed files with 1,183 additions and 789 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
with:
verb: run
args: >-
poetry run python tests/ci/main.py
poetry run python tests/ci/main.py
--git-commit ${{ github.sha }}
--with-linter
--with-formatter
--with-tests
--with-tests
${{ env.PUBLISH_IMAGE == 'TRUE' && format('--publish-docker-image {0}:{1}', env.IMAGE_NAME, env.IMAGE_TAG) || ''}}
version: 0.9.9
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
with:
webhook_url: ${{ secrets.STAGING_WEBHOOK_URL }}
webhook_secret: ${{ secrets.STAGING_WEBHOOK_SECRET }}
webhook_type: json
webhook_type: json
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ backend/.env

/Arpav-PPCV

.venv
.venv
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ Config directory: `docker/nginx`
#### NodeJS (proxy Thredds Data Server)
A NodeJs server-side proxy application can be used to perform a variety of tasks, such as load balancing, caching, and security filtering. For example, a load-balancing proxy can distribute incoming requests among multiple backend servers, improving the scalability and availability of web applications. A caching proxy can store frequently accessed data in memory or on disk, reducing the load on backend servers and improving the performance of web applications. A security filtering proxy can inspect incoming requests and filter out potentially harmful requests or data, protecting web applications from attacks. Node.js is a popular platform for building proxy servers due to its event-driven, non-blocking I/O model, which allows it to handle large numbers of concurrent connections efficiently,

In this application it acts as an intermediary between clients and Thredds Data Server servers, allowing users to access a subset of THREDDS data and services without authentication. It receives requests from clients and forwards them to Thredds Data Server, and then sends the response back to the client.
In this application it acts as an intermediary between clients and Thredds Data Server servers, allowing users to access a subset of THREDDS data and services without authentication. It receives requests from clients and forwards them to Thredds Data Server, and then sends the response back to the client.

Root directory: `backend`

#### Martin
Martin Vector Tile Server is an open-source vector tile server that allows users to serve vector tiles over the web. It is built for MapLibre, an open-source JavaScript library for interactive maps, and supports a variety of data sources, including GeoJSON, PostGIS, and Shapefile.
Martin Vector Tile Server is an open-source vector tile server that allows users to serve vector tiles over the web. It is built for MapLibre, an open-source JavaScript library for interactive maps, and supports a variety of data sources, including GeoJSON, PostGIS, and Shapefile.

# Development

Expand All @@ -69,10 +69,10 @@ For development on your local machine, you need to install the following tools:


#### Prepare the Environment

Starting from the root of the project, clone the backend repository, move on `develop` branch and clone frontend repository inside this project


git clone https://github.com/inkode-it/Arpav-PPCV-backend
cd Arpav-PPCV-backend
git checkout develop
Expand Down Expand Up @@ -100,7 +100,7 @@ NOTE: Both `Arpav-PPCV-backend` & `Arpav-PPCV` (the frontend) have a different .
docker-compose -f docker-compose.dev.yml up --build -d


#### Make django migrations:
#### Make django migrations:

docker exec -ti backend.api python manage.py makemigrations users groups forecastattributes places thredds

Expand Down Expand Up @@ -156,7 +156,7 @@ If everything is ok and you followed also frontend README instructions, you shou
docker-compose up --build -d


#### Make django migrations:
#### Make django migrations:

docker exec -ti backend.api python manage.py makemigrations users groups forecastattributes places thredds

Expand Down
2 changes: 1 addition & 1 deletion arpav_ppcv/migrations/README
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Generic single-database configuration.
Generic single-database configuration.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""initial migration
Revision ID: 659d9a1a2586
Revises:
Revises:
Create Date: 2024-04-15 09:49:37.180158
"""
Expand Down
2 changes: 1 addition & 1 deletion arpav_ppcv/webapp/templates/landing_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ <h1>ARPAV-PPCV backend</h1>
</ul>

</body>
</html>
</html>
2 changes: 1 addition & 1 deletion backend/djangoapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app # noqa
from .celery import app as celery_app # noqa
2 changes: 1 addition & 1 deletion backend/djangoapp/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
django.setup()

#application = routing.application
application = app
application = app
2 changes: 1 addition & 1 deletion backend/djangoapp/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def websocket_receive(self, event):
self.send({
"type": "websocket.send",
"text": event["text"],
})
})
2 changes: 1 addition & 1 deletion backend/djangoapp/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"channel": ChannelNameRouter({
"app": AppConsumer,
}),
})
})
2 changes: 1 addition & 1 deletion backend/djangoapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,4 @@
'user': ARPAV_PPCV.django_app.thredds.user,
'password': ARPAV_PPCV.django_app.thredds.password,
'proxy': ARPAV_PPCV.django_app.thredds.proxy,
}
}
2 changes: 1 addition & 1 deletion backend/djcore/djcore/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1"
__version__ = "0.1"
2 changes: 1 addition & 1 deletion backend/djcore/djcore/core/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ def option_list(self, request, *args, **kwargs):
data = {
'results': results
}
return Response(data)
return Response(data)
2 changes: 1 addition & 1 deletion backend/djcore/djcore/core/serializers.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from rest_framework import serializers
from rest_framework import serializers
2 changes: 1 addition & 1 deletion backend/djcore/djcore/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

urlpatterns = [
url(r'^$', index, name='index'),
]
]
2 changes: 1 addition & 1 deletion backend/djcore/djcore/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def get(self, request, *args, **kwargs):

@api_view(['GET'])
def index(request):
return response.Response({"status": "OK"})
return response.Response({"status": "OK"})
2 changes: 1 addition & 1 deletion backend/djcore/djcore/groups/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1"
__version__ = "0.1"
2 changes: 1 addition & 1 deletion backend/djcore/djcore/groups/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class GroupSerializer(serializers.ModelSerializer):
class Meta:
model = Group
fields = ('name','id')
fields = ('name','id')
2 changes: 1 addition & 1 deletion backend/djcore/djcore/groups/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
router = routers.SimpleRouter()
router.register(r'', GroupListView)

urlpatterns = router.urls
urlpatterns = router.urls
2 changes: 1 addition & 1 deletion backend/djcore/djcore/groups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
class GroupListView(generics.ListAPIView,OptionListModelMixin,viewsets.GenericViewSet):
queryset = Group.objects.all()
serializer_class = GroupSerializer
permission_classes = (DjangoAdminOrObjectPermission,)
permission_classes = (DjangoAdminOrObjectPermission,)
2 changes: 1 addition & 1 deletion backend/djcore/djcore/users/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1"
__version__ = "0.1"
2 changes: 1 addition & 1 deletion backend/djcore/djcore/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ class UserBulkSerializer(BulkSerializerMixin, UserSerializer):
class Meta(object):
model = User
# only necessary in DRF3
list_serializer_class = BulkListSerializer
list_serializer_class = BulkListSerializer
2 changes: 1 addition & 1 deletion backend/djcore/djcore/users/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
router.register(r'destroy', UserBulkView)
router.register(r'', UserViewSet)

urlpatterns = router.urls
urlpatterns = router.urls
2 changes: 1 addition & 1 deletion backend/djcore/djcore/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ def delete(self, request, *args, **kwargs):
return self.bulk_destroy(request, *args, **kwargs)

def allow_bulk_destroy(self, qs, filtered):
return qs is not filtered
return qs is not filtered
2 changes: 1 addition & 1 deletion backend/padoa/forecastattributes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ class ValueTypeAdmin(admin.ModelAdmin):
admin.site.register(DataSeries, DataSeriesAdmin)
admin.site.register(YearPeriod, YearPeriodAdmin)
admin.site.register(TimeWindow, TimeWindowAdmin)
admin.site.register(ValueType, ValueTypeAdmin)
admin.site.register(ValueType, ValueTypeAdmin)
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def add_arguments(self, parser):
"id": "Rcp85",
"name": "rcp8.5",
"description": "",
}
}
],
"DataSeries" : [
{
Expand Down
2 changes: 1 addition & 1 deletion backend/padoa/forecastattributes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ class Meta:
# class TimeRangeSerializer(BaseAttributeSerializer):
# class Meta:
# model = TimeRange
# fields = '__all__'
# fields = '__all__'
2 changes: 1 addition & 1 deletion backend/padoa/forecastattributes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
router.register(r'value_types', ValueTypeList)
#router.register(r'time_range', TimeRangeList)

urlpatterns = router.urls
urlpatterns = router.urls
2 changes: 1 addition & 1 deletion backend/padoa/forecastattributes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ class ValueTypeList(CachedParametersList):

# class TimeRangeList(CachedParametersList):
# queryset = TimeRange.objects.all()
# serializer_class = TimeRangeSerializer
# serializer_class = TimeRangeSerializer
2 changes: 1 addition & 1 deletion backend/padoa/places/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
# return response
#
# export_as_csv.short_description = description
# return export_as_csv
# return export_as_csv
2 changes: 0 additions & 2 deletions backend/padoa/places/management/commands/import_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,3 @@ def handle(self, *args, **options):


self.stdout.write("All regions imported!")


2 changes: 0 additions & 2 deletions backend/padoa/places/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ class Meta:
'latlng',
# 'bbox'
)


1 change: 0 additions & 1 deletion backend/padoa/places/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
router.register(r'cities', CitiesList)

urlpatterns = router.urls

2 changes: 1 addition & 1 deletion backend/padoa/places/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class CitiesList(ListAPIView,GenericViewSet):

@method_decorator(cache_page(3600*7*24))
def list(self, request, *args, **kwargs):
return super().list(request, *args, **kwargs)
return super().list(request, *args, **kwargs)
2 changes: 1 addition & 1 deletion backend/padoa/thredds/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class MapAdmin(GeoModelAdmin):


admin.site.register(Map, MapAdmin)
admin.site.register(UserDownload)
admin.site.register(UserDownload)
10 changes: 5 additions & 5 deletions backend/padoa/thredds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ class Map(models.Model):
csr = models.CharField(max_length=255,null=True, blank=True, default='CRS:84')
spatialbounds = models.PolygonField (blank=True, null=True)
# LAYER
layer_id = models.CharField(max_length=255, null=False, blank=False)
layer_id = models.CharField(max_length=255, null=False, blank=False)
# layer_name = models.CharField(max_length=255, null=False, blank=False) #removed
path = models.CharField(max_length=400, null=False, blank=False)
path = models.CharField(max_length=400, null=False, blank=False)
# layer_url = models.URLField(max_length=800, blank=False, null=False)
elevation = models.IntegerField(null=True, blank=True)
# style = models.CharField(max_length=255, null=True, blank=True)
palette = models.CharField(max_length=255, null=True, blank=True)
palette = models.CharField(max_length=255, null=True, blank=True)
unit = models.CharField(max_length=255, null=True, blank=True)
# numcolorbands = models.IntegerField(default=80)
# color_scale_range = models.CharField(max_length=255, null=True, blank=True)
color_scale_min = models.IntegerField(null=True, blank=True)
color_scale_max = models.IntegerField(null=True, blank=True)
color_scale_min = models.IntegerField(null=True, blank=True)
color_scale_max = models.IntegerField(null=True, blank=True)

### MAP MODEL:
class UserDownload(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion backend/padoa/thredds/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
router = routers.SimpleRouter()
router.register(r'maps', MapList)

urlpatterns = [
urlpatterns = [
# path('wms/timeserie/', TimeSeries.as_view()),
path('ncss/timeserie/', NCSSTimeserie.as_view()),
path('ncss/netcdf/', NCSSSubset.as_view())
Expand Down
1 change: 0 additions & 1 deletion backend/padoa/thredds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,3 @@ def get(self, request):

#http://localhost:8000/thredds/ncss/netcdf/?id=7&time_start=1976-07-17T00%3A00%3A00Z&time_end=2099-07-17T00%3A00%3A00Z&north=46.0&west=13.0&east=14&south=45
#http://192.167.167.61:8000/thredds/ncss/netcdf/?id=7&time_start=1976-07-17T00%3A00%3A00Z&time_end=2099-07-17T00%3A00%3A00Z&north=46.0&west=13.0&east=14&south=45

2 changes: 1 addition & 1 deletion backend/resources/places/limits_IT_municipalities.geojson

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/resources/places/limits_IT_provinces.geojson

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/resources/places/limits_IT_regions.geojson

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/basemap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ ADD italy-latest.osm.pbf /app/italy-latest.osm.pbf

RUN tilemaker --input italy-latest.osm.pbf --output italy.mbtiles --config tilemaker/resources/config-openmaptiles.json --process tilemaker/resources/process-openmaptiles.lua

#RUN #apt update && apt install -y wget tilemaker
#RUN #apt update && apt install -y wget tilemaker
2 changes: 1 addition & 1 deletion docker/basemap/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ services:
ports:
- 8888:8888
environment:
NODE_ENV: 'development'
NODE_ENV: 'development'
2 changes: 1 addition & 1 deletion docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ services:
image: 'ghcr.io/maplibre/martin:v0.13.0'
depends_on:
db:
condition: service_healthy
condition: service_healthy
1 change: 0 additions & 1 deletion docker/thredds/content-root/catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@

<catalogRef xlink:title="Catalogo modelli climatici" xlink:href="catalog_rcm.xml" name=""/>
</catalog>

Loading

0 comments on commit 165ffaa

Please sign in to comment.