Skip to content

Commit 1370cde

Browse files
authored
Merge pull request #1037 from hubmapconsortium/sunset666/directory_permissions_reorganization
Adding permissions reset to reorganized datasets
2 parents 73016c8 + 88cda3a commit 1370cde

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/ingest-pipeline/airflow/dags/reorganize_upload.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from airflow.operators.bash import BashOperator
1616
from airflow.exceptions import AirflowException
1717
from airflow.providers.http.hooks.http import HttpHook
18+
from airflow.decorators import task
1819

1920
from hubmap_operators.common_operators import (
2021
LogInfoOperator,
@@ -38,6 +39,8 @@
3839
)
3940

4041
from misc.tools.split_and_create import reorganize
42+
from misc.tools.set_standard_protections import process_one_uuid
43+
from misc.tools.survey import EntityFactory
4144

4245

4346
# Following are defaults which can be overridden later on
@@ -299,6 +302,21 @@ def my_callable(**kwargs):
299302
def xcom_consistency_puller(**kwargs):
300303
return kwargs["ti"].xcom_pull(task_ids="split_stage_2", key="child_uuid_list")
301304

305+
306+
@task(task_id="permission_resetting")
307+
def permission_resetting(**kwargs):
308+
return_error = []
309+
entity_host = HttpHook.get_connection("entity_api_connection").host
310+
entity_factory = EntityFactory(get_auth_tok(**kwargs),
311+
instance=find_matching_endpoint(entity_host))
312+
for uuid in kwargs["ti"].xcom_pull(task_ids="split_stage_2", key="child_uuid_list"):
313+
return_error.append(process_one_uuid(uuid, entity_factory))
314+
if False in return_error:
315+
return 1
316+
return 0
317+
318+
t_reset_permissions = permission_resetting()
319+
302320
t_md_consistency_tests = PythonOperator(
303321
task_id="md_consistency_tests",
304322
python_callable=utils.pythonop_md_consistency_tests,
@@ -414,6 +432,7 @@ def _get_upload_uuid(**kwargs):
414432
>> t_maybe_keep_2
415433
>> t_run_md_extract
416434
>> t_md_consistency_tests
435+
>> t_reset_permissions
417436
>> t_send_status
418437
>> t_join
419438
>> t_preserve_info

src/ingest-pipeline/misc/tools/set_standard_protections.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
from io import StringIO
1010
from typing import List
1111

12-
from survey import Dataset, EntityFactory, is_uuid
12+
try:
13+
from survey import Dataset, EntityFactory, is_uuid
14+
except ImportError:
15+
from .survey import Dataset, EntityFactory, is_uuid
1316

1417

1518
logging.basicConfig()
@@ -33,7 +36,7 @@ def run_cmd(cmd: List[str]) -> int :
3336
return command.returncode
3437

3538

36-
def process_one_uuid(uuid: str, entity_factory: EntityFactory, **kwargs) -> bool :
39+
def process_one_uuid(uuid: str, entity_factory: EntityFactory, **kwargs) -> bool:
3740
LOGGER.info('handling uuid %s', uuid)
3841
try:
3942
ds = entity_factory.get(uuid)
@@ -64,7 +67,7 @@ def process_one_uuid(uuid: str, entity_factory: EntityFactory, **kwargs) -> bool
6467
acl_path = Path(__file__).absolute().parent.parent.parent / 'submodules'
6568
acl_path = acl_path / 'manual-data-ingest' / 'acl-settings' / acl_fname
6669
LOGGER.info('will apply %s', acl_path)
67-
cmd1 = ['setfacl', '-b', str(ds.full_path)]
70+
cmd1 = ['setfacl', '-bR', str(ds.full_path)]
6871
cmd2 = ['setfacl', '-R', '-M', str(acl_path), str(ds.full_path)]
6972
if kwargs.get('dry_run', False):
7073
cmd1.insert(1, '--test')

0 commit comments

Comments
 (0)