Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed GRASS GIS locations to projects #565

Merged
merged 31 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
19c6f4a
add decorator for deprecated locations
anikaweinmann Oct 16, 2024
0b1e445
linting
anikaweinmann Oct 17, 2024
a327f27
add project endpoints
anikaweinmann Oct 17, 2024
3ea49a9
endpoints for projects
anikaweinmann Oct 17, 2024
32e9034
rename location
anikaweinmann Oct 17, 2024
fd11517
rename location
anikaweinmann Oct 17, 2024
628ac83
unify maintainer
anikaweinmann Oct 17, 2024
e3c8a54
fix GRASS Initialisation
anikaweinmann Oct 17, 2024
49b4418
black
anikaweinmann Oct 17, 2024
2ef9463
fixes for tests and G83
anikaweinmann Oct 18, 2024
eff93b7
fixes
anikaweinmann Nov 14, 2024
dc672e1
add rest of changes
anikaweinmann Nov 15, 2024
bd3a7a0
CT review
anikaweinmann Nov 15, 2024
7498542
CT review
anikaweinmann Nov 15, 2024
8c1d5cb
Update tests/test_job_resumption.py
anikaweinmann Nov 15, 2024
4cc99f5
fix endpoints
anikaweinmann Nov 15, 2024
211c500
Merge branch 'renamed_locations' of github.com:actinia-org/actinia-co…
anikaweinmann Nov 15, 2024
ed2565f
fix job resumption tests
anikaweinmann Nov 15, 2024
a06ddf1
linting
anikaweinmann Nov 15, 2024
3ec62c3
Update src/actinia_core/core/common/api_logger.py
anikaweinmann Nov 20, 2024
f3ce464
Tests for G84
anikaweinmann Nov 21, 2024
1515f51
Test pipelines for G8.3 and G8.4
anikaweinmann Nov 21, 2024
ea142b5
Merge branch 'renamed_locations' of github.com:actinia-org/actinia-co…
anikaweinmann Nov 21, 2024
587a56e
Update src/actinia_core/rest/base/resource_base.py
anikaweinmann Nov 21, 2024
5d5e8a8
Merge branch 'main' into renamed_locations
anikaweinmann Nov 21, 2024
a6c24d8
fix test workflow
anikaweinmann Nov 21, 2024
71419f6
Merge branch 'renamed_locations' of github.com:actinia-org/actinia-co…
anikaweinmann Nov 21, 2024
52736cc
fix tests for G83
anikaweinmann Nov 21, 2024
9a43d65
fix error due to lib update
mmacata Dec 3, 2024
378795a
fix proc name
mmacata Dec 3, 2024
2ed0c9d
Update src/actinia_core/endpoints.py
anikaweinmann Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/actinia_core/core/common/api_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def add_entry(self, user_id, http_request):

"""
api_info = {
"endpoint": http_request.endpoint,
# For depricated location endpoints remove "_locations" from
anikaweinmann marked this conversation as resolved.
Show resolved Hide resolved
# endpoint class name
"endpoint": http_request.endpoint.replace("_locations", ""),
mmacata marked this conversation as resolved.
Show resolved Hide resolved
"method": http_request.method,
"path": http_request.path,
"request_url": http_request.url,
Expand Down
165 changes: 104 additions & 61 deletions src/actinia_core/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@
__email__ = "[email protected]"


def get_endpoint_class_name(endpoint_class, projects_url_part="projects"):
endpoint_class_name = endpoint_class.__name__.lower()
if "project" in endpoint_class_name:
name = endpoint_class_name.replace("project", projects_url_part[:-1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this replace "project" with "project"? Why is this needed?

elif projects_url_part != "projects":
name = f"{endpoint_class_name}_{projects_url_part}"
else:
name = endpoint_class_name
return name
anikaweinmann marked this conversation as resolved.
Show resolved Hide resolved


def create_project_endpoints(projects_url_part="projects"):
"""Function to add resources with "project" inside the endpoint url.

Expand All @@ -141,229 +152,261 @@ def create_project_endpoints(projects_url_part="projects"):
URL; to add deprecated location endpoints set
it to "locations"
"""

# Project management
flask_api.add_resource(
ListProjectsResource,
f"/{projects_url_part}",
endpoint=f"/{projects_url_part}",
endpoint=get_endpoint_class_name(
ListProjectsResource, projects_url_part
),
)
flask_api.add_resource(
ProjectManagementResourceUser,
f"/{projects_url_part}/<string:project_name>/info",
endpoint=f"/{projects_url_part}/<string:project_name>/info",
endpoint=get_endpoint_class_name(
ProjectManagementResourceUser, projects_url_part
),
)
flask_api.add_resource(
ProjectManagementResourceAdminUser,
f"/{projects_url_part}/<string:project_name>",
endpoint=f"/{projects_url_part}/<string:project_name>",
endpoint=get_endpoint_class_name(
ProjectManagementResourceAdminUser, projects_url_part
),
)

# Mapset management
flask_api.add_resource(
ListMapsetsResource,
f"/{projects_url_part}/<string:project_name>/mapsets",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets",
endpoint=get_endpoint_class_name(
ListMapsetsResource, projects_url_part
),
)
flask_api.add_resource(
MapsetManagementResourceUser,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/info",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/info",
endpoint=get_endpoint_class_name(
MapsetManagementResourceUser, projects_url_part
),
)
flask_api.add_resource(
MapsetManagementResourceAdmin,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>",
endpoint=get_endpoint_class_name(
MapsetManagementResourceAdmin, projects_url_part
),
)
flask_api.add_resource(
MapsetLockManagementResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/lock",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/lock",
endpoint=get_endpoint_class_name(
MapsetLockManagementResource, projects_url_part
),
)

# Raster management
flask_api.add_resource(
RasterLayersResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers",
endpoint=get_endpoint_class_name(
RasterLayersResource, projects_url_part
),
)
flask_api.add_resource(
RasterLayerResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>",
endpoint=get_endpoint_class_name(
RasterLayerResource, projects_url_part
),
)
flask_api.add_resource(
SyncEphemeralRasterLegendResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/legend",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/legend",
endpoint=get_endpoint_class_name(
SyncEphemeralRasterLegendResource, projects_url_part
),
)
flask_api.add_resource(
SyncPersistentRasterColorsResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/colors",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/colors",
endpoint=get_endpoint_class_name(
SyncPersistentRasterColorsResource, projects_url_part
),
)
flask_api.add_resource(
SyncEphemeralRasterRendererResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/render",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/render",
endpoint=get_endpoint_class_name(
SyncEphemeralRasterRendererResource, projects_url_part
),
)
flask_api.add_resource(
SyncEphemeralRasterRGBRendererResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/render_rgb",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/render_rgb",
endpoint=get_endpoint_class_name(
SyncEphemeralRasterRGBRendererResource, projects_url_part
),
)
flask_api.add_resource(
SyncEphemeralRasterShapeRendererResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/render_shade",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/render_shade",
endpoint=get_endpoint_class_name(
SyncEphemeralRasterShapeRendererResource, projects_url_part
),
)
# STRDS management
flask_api.add_resource(
SyncSTRDSListerResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds",
endpoint=get_endpoint_class_name(
SyncSTRDSListerResource, projects_url_part
),
)
flask_api.add_resource(
STRDSManagementResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds/<string:strds_name>",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds/<string:strds_name>",
endpoint=get_endpoint_class_name(
STRDSManagementResource, projects_url_part
),
)
flask_api.add_resource(
STRDSRasterManagement,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds/<string:strds_name>/raster_layers",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds/<string:strds_name>/raster_layers",
endpoint=get_endpoint_class_name(
STRDSRasterManagement, projects_url_part
),
)
# Vector management
flask_api.add_resource(
VectorLayersResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/vector_layers",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/vector_layers",
endpoint=get_endpoint_class_name(
VectorLayersResource, projects_url_part
),
)
flask_api.add_resource(
VectorLayerResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/vector_layers/<string:vector_name>",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/vector_layers/<string:vector_name>",
endpoint=get_endpoint_class_name(
VectorLayerResource, projects_url_part
),
)
flask_api.add_resource(
SyncEphemeralVectorRendererResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/vector_layers/<string:vector_name>/render",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/vector_layers/<string:vector_name>/render",
endpoint=get_endpoint_class_name(
SyncEphemeralVectorRendererResource, projects_url_part
),
)
flask_api.add_resource(
SyncEphemeralSTRDSRendererResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds/<string:strds_name>/render",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/strds/<string:strds_name>/render",
endpoint=get_endpoint_class_name(
SyncEphemeralSTRDSRendererResource, projects_url_part
),
)

# Validation
flask_api.add_resource(
AsyncProcessValidationResource,
f"/{projects_url_part}/<string:project_name>/"
"process_chain_validation_async",
endpoint=f"/{projects_url_part}/<string:project_name>/"
"process_chain_validation_async",
endpoint=get_endpoint_class_name(
AsyncProcessValidationResource, projects_url_part
),
)

flask_api.add_resource(
SyncProcessValidationResource,
f"/{projects_url_part}/<string:project_name>/"
"process_chain_validation_sync",
endpoint=f"/{projects_url_part}/<string:project_name>/"
"process_chain_validation_sync",
endpoint=get_endpoint_class_name(
SyncProcessValidationResource, projects_url_part
),
)

# Async processing
flask_api.add_resource(
AsyncEphemeralResource,
f"/{projects_url_part}/<string:project_name>/processing_async",
endpoint=f"/{projects_url_part}/<string:project_name>/"
"processing_async",
endpoint=get_endpoint_class_name(
AsyncEphemeralResource, projects_url_part
),
)
flask_api.add_resource(
AsyncEphemeralExportResource,
f"/{projects_url_part}/<string:project_name>/processing_async_export",
endpoint=f"/{projects_url_part}/<string:project_name>/"
"processing_async_export",
endpoint=get_endpoint_class_name(
AsyncEphemeralExportResource, projects_url_part
),
)
flask_api.add_resource(
AsyncEphemeralExportS3Resource,
f"/{projects_url_part}/<string:project_name>/"
"processing_async_export_s3",
endpoint=f"/{projects_url_part}/<string:project_name>/"
"processing_async_export_s3",
endpoint=get_endpoint_class_name(
AsyncEphemeralExportS3Resource, projects_url_part
),
)
flask_api.add_resource(
AsyncEphemeralExportGCSResource,
f"/{projects_url_part}/<string:project_name>/"
"processing_async_export_gcs",
endpoint=f"/{projects_url_part}/<string:project_name>/"
"processing_async_export_gcs",
endpoint=get_endpoint_class_name(
AsyncEphemeralExportGCSResource, projects_url_part
),
)
flask_api.add_resource(
AsyncPersistentResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/processing_async",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/processing_async",
endpoint=get_endpoint_class_name(
AsyncPersistentResource, projects_url_part
),
)
flask_api.add_resource(
AsyncPersistentMapsetMergerResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/merging_async",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/merging_async",
endpoint=get_endpoint_class_name(
AsyncPersistentMapsetMergerResource, projects_url_part
),
)
flask_api.add_resource(
AsyncEphemeralRasterLayerExporterResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/"
"geotiff_async",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/"
"geotiff_async",
endpoint=get_endpoint_class_name(
AsyncEphemeralRasterLayerExporterResource, projects_url_part
),
)
flask_api.add_resource(
AsyncEphemeralRasterLayerRegionExporterResource,
f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/"
"geotiff_async_orig",
endpoint=f"/{projects_url_part}/<string:project_name>/mapsets/"
"<string:mapset_name>/raster_layers/<string:raster_name>/"
"geotiff_async_orig",
endpoint=get_endpoint_class_name(
AsyncEphemeralRasterLayerRegionExporterResource, projects_url_part
),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,17 @@ def _execute(self):
project_param = "location" if grass_version < [8, 4] else "project"
pc = {
"version": 1,
"list": [{
"id": "1",
"module": "g.proj",
"inputs": [
{"param": "epsg", "value": epsg_code},
{"param": project_param, "value": new_project},
],
"flags": "t",
}]
"list": [
{
"id": "1",
"module": "g.proj",
"inputs": [
{"param": "epsg", "value": epsg_code},
{"param": project_param, "value": new_project},
],
"flags": "t",
}
],
}

process_list = self._validate_process_chain(
Expand Down
4 changes: 3 additions & 1 deletion src/actinia_core/rest/base/resource_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ def __init__(self, resource_id=None, iteration=None, post_url=None):

# Put API information in the response for later accounting
kwargs = {
"endpoint": request.endpoint,
# For depricated location endpoints remove "_locations" from
anikaweinmann marked this conversation as resolved.
Show resolved Hide resolved
# endpoint class name
"endpoint": request.endpoint.replace("_locations", ""),
mmacata marked this conversation as resolved.
Show resolved Hide resolved
"method": request.method,
"path": request.path,
"request_url": self.request_url,
Expand Down
Loading
Loading