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

Add support for wildcard import files in manifest.json #1198

Merged
merged 4 commits into from
Jan 24, 2025
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
38 changes: 30 additions & 8 deletions import-automation/executor/app/executor/import_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))))
sys.path.append(os.path.join(REPO_DIR, 'tools', 'import_differ'))
sys.path.append(os.path.join(REPO_DIR, 'tools', 'import_validation'))
sys.path.append(os.path.join(REPO_DIR, 'util'))

import file_util

from import_differ import ImportDiffer
from import_validation import ImportValidation
Expand Down Expand Up @@ -536,13 +539,32 @@ def _upload_import_inputs(
for import_input in import_inputs:
for input_type in self.config.import_input_types:
path = import_input.get(input_type)
if path:
dest = f'{output_dir}/{version}/{os.path.basename(path)}'
self._upload_file_helper(
src=os.path.join(import_dir, path),
dest=dest,
)
setattr(uploaded, input_type, dest)
if not path:
continue
for file in file_util.file_get_matching(
os.path.join(import_dir, path)):
if file:
dest = f'{output_dir}/{version}/{os.path.basename(file)}'
self._upload_file_helper(
src=file,
dest=dest,
)
uploaded_dest = f'{output_dir}/{version}/{os.path.basename(path)}'
setattr(uploaded, input_type, uploaded_dest)

# Upload any files downloaded from source
source_files = [
os.path.join(import_dir, file)
for file in import_spec.get('source_files', [])
]
source_files = file_util.file_get_matching(source_files)
for file in source_files:
dest = f'{output_dir}/{version}/source_files/{os.path.basename(file)}'
self._upload_file_helper(
src=file,
dest=dest,
)

self.uploader.upload_string(
version,
os.path.join(output_dir, self.config.storage_version_filename))
Expand All @@ -565,7 +587,7 @@ def _import_metadata_mcf_helper(self, import_spec: dict) -> str:

Args:
import_spec: Specification of the import as a dict.

Returns:
import_metadata_mcf node.
"""
Expand Down
2 changes: 0 additions & 2 deletions tools/statvar_importer/config_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@
flags.DEFINE_bool('llm_generate_statvar_name', False,
'Generate names for Statvars.')

_FLAGS(sys.argv) # Allow invocation without app.run()


def get_default_config() -> dict:
"""Returns the default config as dictionary of config parameters and values."""
Expand Down
2 changes: 1 addition & 1 deletion util/dc_api_wrapper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_dc_api_is_defined_dcid(self):

def test_dc_get_node_property_values(self):
"""Test API wrapper to get all property:values for a node."""
node_pvs = dc_api.dc_api_get_node_property_values(['dcs:Count_Person'])
node_pvs = dc_api.dc_api_get_node_property_values(['dcid:Count_Person'])
self.assertTrue(node_pvs)
# Verify the resposnse has dcid with the namespace prefix 'dcid:'
self.assertTrue('dcid:Count_Person' in node_pvs)
Expand Down
Loading