Skip to content

Commit

Permalink
Merge pull request #1037 from hubmapconsortium/sunset666/directory_pe…
Browse files Browse the repository at this point in the history
…rmissions_reorganization

Adding permissions reset to reorganized datasets
  • Loading branch information
sunset666 authored Mar 5, 2025
2 parents 73016c8 + 88cda3a commit 1370cde
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/ingest-pipeline/airflow/dags/reorganize_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from airflow.operators.bash import BashOperator
from airflow.exceptions import AirflowException
from airflow.providers.http.hooks.http import HttpHook
from airflow.decorators import task

from hubmap_operators.common_operators import (
LogInfoOperator,
Expand All @@ -38,6 +39,8 @@
)

from misc.tools.split_and_create import reorganize
from misc.tools.set_standard_protections import process_one_uuid
from misc.tools.survey import EntityFactory


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


@task(task_id="permission_resetting")
def permission_resetting(**kwargs):
return_error = []
entity_host = HttpHook.get_connection("entity_api_connection").host
entity_factory = EntityFactory(get_auth_tok(**kwargs),
instance=find_matching_endpoint(entity_host))
for uuid in kwargs["ti"].xcom_pull(task_ids="split_stage_2", key="child_uuid_list"):
return_error.append(process_one_uuid(uuid, entity_factory))
if False in return_error:
return 1
return 0

t_reset_permissions = permission_resetting()

t_md_consistency_tests = PythonOperator(
task_id="md_consistency_tests",
python_callable=utils.pythonop_md_consistency_tests,
Expand Down Expand Up @@ -414,6 +432,7 @@ def _get_upload_uuid(**kwargs):
>> t_maybe_keep_2
>> t_run_md_extract
>> t_md_consistency_tests
>> t_reset_permissions
>> t_send_status
>> t_join
>> t_preserve_info
Expand Down
9 changes: 6 additions & 3 deletions src/ingest-pipeline/misc/tools/set_standard_protections.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from io import StringIO
from typing import List

from survey import Dataset, EntityFactory, is_uuid
try:
from survey import Dataset, EntityFactory, is_uuid
except ImportError:
from .survey import Dataset, EntityFactory, is_uuid


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


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

0 comments on commit 1370cde

Please sign in to comment.