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

169 Test chunk PATCH layer with .zip file for ShapeFile and raster types #504

Merged
merged 4 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion src/layman/layer/filesystem/input_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def get_layer_info(workspace, layername):
if info:
files_to_upload = info['files_to_upload']
file_names = [file['input_file'] for file in files_to_upload]
file_type = input_file.get_file_type(input_file.get_main_file_name(file_names))
if len(file_names) == 1 and input_file.get_compressed_main_file_extension(file_names[0]):
file_type = settings.FILE_TYPE_UNKNOWN
else:
file_type = input_file.get_file_type(input_file.get_main_file_name(file_names))
result = {'file': {'file_type': file_type}}
return result

Expand Down
11 changes: 8 additions & 3 deletions src/layman/layer/rest_workspace_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def patch(workspace, layername):
]
if len(files) > 0:
use_chunk_upload = True
if len(files) == 1 and input_file.get_compressed_main_file_extension(files[0]):
zipped_file = files[0]

# CRS
crs_id = None
Expand Down Expand Up @@ -106,14 +108,17 @@ def patch(workspace, layername):
# FILE NAMES
filenames = None
if delete_from == 'layman.layer.filesystem.input_file':
if use_chunk_upload:
if use_chunk_upload and zipped_file:
filenames = list()
elif use_chunk_upload:
filenames = files
elif zipped_file:
filenames = fs_util.get_filenames_from_zip_storage(zipped_file, with_zip_in_path=True)
else:
filenames = [f.filename for f in files]
input_file.check_filenames(workspace, layername, filenames,
check_crs, ignore_existing_files=True)
if not (use_chunk_upload and zipped_file):
input_file.check_filenames(workspace, layername, filenames,
check_crs, ignore_existing_files=True)
# file checks
if not use_chunk_upload:
temp_dir = tempfile.mkdtemp(prefix="layman_")
Expand Down
4 changes: 2 additions & 2 deletions src/layman/layer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from flask import current_app, request, g

from layman import LaymanError, patch_mode, util as layman_util
from layman import LaymanError, patch_mode, util as layman_util, settings
from layman.util import call_modules_fn, get_providers_from_source_names, get_internal_sources, \
to_safe_name, url_for
from layman import celery as celery_util, common
Expand Down Expand Up @@ -75,7 +75,7 @@ def check_new_layername(workspace, layername):

def fill_in_partial_info_statuses(info, chain_info):
file_type = info.get('file', dict()).get('file_type')
item_keys = get_layer_info_keys(file_type) if file_type else None
item_keys = get_layer_info_keys(file_type) if file_type else settings.FILE_TYPE_UNKNOWN

return layman_util.fill_in_partial_info_statuses(info, chain_info, TASKS_TO_LAYER_INFO_KEYS, item_keys)

Expand Down
100 changes: 100 additions & 0 deletions tests/dynamic_data/publications.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,31 @@
}),
],
},
{
consts.KEY_ACTION: {
consts.KEY_CALL: Action(process_client.patch_workspace_publication, {
**predefined_zip_files.NE_110M_ADMIN_0_BOUNDARY_LINES_LAND,
'with_chunks': True,
}),
consts.KEY_RESPONSE_ASSERTS: [
Action(processing.response.valid_post, dict()),
],
},
consts.KEY_FINAL_ASSERTS: [
*publication.IS_LAYER_COMPLETE_AND_CONSISTENT,
Action(publication.internal.correct_values_in_detail, {
'exp_publication_detail': {
'bounding_box': [-15695801.072582014, -7341864.739114417, 15699816.562538767, 11122367.192100529],
},
'file_extension': 'zip/ne_110m_admin_0_boundary lines land +ěščřžýáí/ne_110m_admin_0_boundary_lines_land ížě.shp',
'gdal_prefix': '/vsizip/',
'publ_type_detail': ('vector', 'sld'),
}),
Action(publication.internal.thumbnail_equals, {
'exp_thumbnail': 'test_tools/data/thumbnail/ne_110m_admin_0_boundary_lines_land.png',
}),
],
},
],
Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_chunks_shp_sld'): [
{
Expand Down Expand Up @@ -366,6 +391,31 @@
}),
],
},
{
consts.KEY_ACTION: {
consts.KEY_CALL: Action(process_client.patch_workspace_publication, {
**predefined_zip_files.SMALL_LAYER_ZIP,
'with_chunks': True,
}),
consts.KEY_RESPONSE_ASSERTS: [
Action(processing.response.valid_post, dict()),
],
},
consts.KEY_FINAL_ASSERTS: [
*publication.IS_LAYER_COMPLETE_AND_CONSISTENT,
Action(publication.internal.correct_values_in_detail, {
'exp_publication_detail': {
'bounding_box': [1571204.369948366, 6268896.225570714, 1572590.854206196, 6269876.33561699],
},
'file_extension': 'zip/small_layer.geojson',
'gdal_prefix': '/vsizip/',
'publ_type_detail': ('vector', 'sld'),
}),
Action(publication.internal.thumbnail_equals, {
'exp_thumbnail': 'sample/style/basic_sld.png',
}),
],
},
],
Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_chunks_tif_tfw_rgba_opaque'): [
{
Expand Down Expand Up @@ -393,6 +443,31 @@
}),
],
},
{
consts.KEY_ACTION: {
consts.KEY_CALL: Action(process_client.patch_workspace_publication, {
**predefined_zip_files.SAMPLE_TIF_COLORTABLE_NODATA_OPAQUE,
'with_chunks': True,
}),
consts.KEY_RESPONSE_ASSERTS: [
Action(processing.response.valid_post, dict()),
],
},
consts.KEY_FINAL_ASSERTS: [
*publication.IS_LAYER_COMPLETE_AND_CONSISTENT,
Action(publication.internal.correct_values_in_detail, {
'exp_publication_detail': {
'bounding_box': [868376.0, 522128.0, 940583.0, 593255.0],
},
'file_extension': 'zip/sample_tif_colortable_nodata_opaque/sample_tif_colortable_nodata_opaque.tif',
'gdal_prefix': '/vsizip/',
'publ_type_detail': ('raster', 'sld'),
}),
Action(publication.internal.thumbnail_equals, {
'exp_thumbnail': 'test_tools/data/thumbnail/raster_layer_tif_colortable_nodata_opaque.png',
}),
],
},
],
Publication(consts.COMMON_WORKSPACE, consts.LAYER_TYPE, 'zipped_chunks_tif_colortable_nodata_opaque'): [
{
Expand Down Expand Up @@ -420,5 +495,30 @@
}),
],
},
{
consts.KEY_ACTION: {
consts.KEY_CALL: Action(process_client.patch_workspace_publication, {
**predefined_zip_files.SAMPLE_TIF_TFW_RGBA_OPAQUE,
'with_chunks': True,
}),
consts.KEY_RESPONSE_ASSERTS: [
Action(processing.response.valid_post, dict()),
],
},
consts.KEY_FINAL_ASSERTS: [
*publication.IS_LAYER_COMPLETE_AND_CONSISTENT,
Action(publication.internal.correct_values_in_detail, {
'exp_publication_detail': {
'bounding_box': [1669480.0, 6580973.000000007, 1675351.9999999802, 6586999.0],
},
'file_extension': 'zip/sample_tif_tfw_rgba_opaque/sample_tif_tfw_rgba_opaque/sample_tif_tfw_rgba_opaque/sample_tif_tfw_rgba_opaque.tif',
'gdal_prefix': '/vsizip/',
'publ_type_detail': ('raster', 'sld'),
}),
Action(publication.internal.thumbnail_equals, {
'exp_thumbnail': 'test_tools/data/thumbnail/raster_layer_tiff.png',
}),
],
},
],
}