From 981a83ec5adc069b651a55ed7343cee3eaba3d81 Mon Sep 17 00:00:00 2001 From: YIDING-CODER Date: Wed, 27 Apr 2022 19:28:07 +1000 Subject: [PATCH 1/5] Removed Unnecessary Manifest --- planutils/packages/cerberus-sat/manifest.json | 31 ---------------- .../forbiditerative-topk/manifest.json | 36 ------------------- planutils/packages/lama-first/manifest.json | 31 ---------------- planutils/packages/lama/manifest.json | 31 ---------------- 4 files changed, 129 deletions(-) delete mode 100644 planutils/packages/cerberus-sat/manifest.json delete mode 100644 planutils/packages/forbiditerative-topk/manifest.json delete mode 100644 planutils/packages/lama-first/manifest.json delete mode 100644 planutils/packages/lama/manifest.json diff --git a/planutils/packages/cerberus-sat/manifest.json b/planutils/packages/cerberus-sat/manifest.json deleted file mode 100644 index 95790cc..0000000 --- a/planutils/packages/cerberus-sat/manifest.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "Cerberus planner for satisficing planning", - "description": "https://github.com/ctpelok77/fd-red-black-postipc2018", - "install-size": "20K", - "dependencies": [ - "cerberus" - ], - "endpoint": { - "services": { - "solve": { - "args": [ - { - "name": "domain", - "type": "file", - "description": "domain file" - }, - { - "name": "problem", - "type": "file", - "description": "problem file" - } - ], - "call": "cerberus-sat {domain} {problem}", - "return": { - "type": "generic", - "files": "*plan*" - } - } - } - } -} \ No newline at end of file diff --git a/planutils/packages/forbiditerative-topk/manifest.json b/planutils/packages/forbiditerative-topk/manifest.json deleted file mode 100644 index 0ac7b20..0000000 --- a/planutils/packages/forbiditerative-topk/manifest.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "Forbid-Iterative top-k planner", - "description": "https://github.com/IBM/forbiditerative", - "install-size": "20K", - "dependencies": [ - "forbiditerative" - ], - "endpoint": { - "services": { - "solve": { - "args": [ - { - "name": "domain", - "type": "file", - "description": "domain file" - }, - { - "name": "problem", - "type": "file", - "description": "problem file" - }, - { - "name": "number_of_plans", - "type": "int", - "description": "Number of Plans" - } - ], - "call": "forbiditerative-topk {domain} {problem} {number_of_plans}", - "return": { - "type": "generic", - "files": "found_plans/done/sas_plan.*" - } - } - } - } -} \ No newline at end of file diff --git a/planutils/packages/lama-first/manifest.json b/planutils/packages/lama-first/manifest.json deleted file mode 100644 index 677dcd9..0000000 --- a/planutils/packages/lama-first/manifest.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "LAMA-FIRST", - "description": "http://fast-downward.org/", - "install-size": "20K", - "dependencies": [ - "downward" - ], - "endpoint": { - "services": { - "solve": { - "args": [ - { - "name": "domain", - "type": "file", - "description": "domain file" - }, - { - "name": "problem", - "type": "file", - "description": "problem file" - } - ], - "call": "lama-first {domain} {problem}", - "return": { - "type": "generic", - "files": "*plan*" - } - } - } - } -} \ No newline at end of file diff --git a/planutils/packages/lama/manifest.json b/planutils/packages/lama/manifest.json deleted file mode 100644 index 71b02ca..0000000 --- a/planutils/packages/lama/manifest.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "LAMA", - "description": "http://fast-downward.org/", - "install-size": "20K", - "dependencies": [ - "downward" - ], - "endpoint": { - "services": { - "solve": { - "args": [ - { - "name": "domain", - "type": "file", - "description": "domain file" - }, - { - "name": "problem", - "type": "file", - "description": "problem file" - } - ], - "call": "lama {domain} {problem}", - "return": { - "type": "generic", - "files": "*plan*" - } - } - } - } -} \ No newline at end of file From 5403de1e94118ed688fe35eeb7c653a7f80ad4fe Mon Sep 17 00:00:00 2001 From: Christian Muise Date: Mon, 2 May 2022 15:57:39 -0400 Subject: [PATCH 2/5] Untested change to allow for compact manifests in manifest.json. --- planutils/__init__.py | 4 +++- planutils/manifest_converter.py | 26 +++++++++++++++++++++++--- planutils/package_installation.py | 1 - planutils/settings.py | 3 +++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/planutils/__init__.py b/planutils/__init__.py index ba3e2d5..d1f616d 100644 --- a/planutils/__init__.py +++ b/planutils/__init__.py @@ -3,6 +3,7 @@ from pathlib import Path from planutils import settings +from planutils import manifest_converter from planutils.package_installation import PACKAGES @@ -13,6 +14,7 @@ def minimal_setup(): print(f"Creating {planutils_dir}...") planutils_dir.mkdir() os.symlink(script_dir / "packages", planutils_dir / "packages") + manifest_converter.backup_manifest() settings.save({'installed': []}) @@ -96,7 +98,7 @@ def main(): parser_upgrade = subparsers.add_parser('upgrade', help='upgrade all of the installed packages') args = parser.parse_args() - + if 'setup' == args.command: setup() return diff --git a/planutils/manifest_converter.py b/planutils/manifest_converter.py index b361bea..d671a18 100644 --- a/planutils/manifest_converter.py +++ b/planutils/manifest_converter.py @@ -3,6 +3,7 @@ import glob import os import copy +import shutil def load_json(f_name): @@ -60,8 +61,27 @@ def generate_manifest(): manifest_compact=load_json(manifest_compact_loc) manifest_full=generate_full_manifest(service_templates,manifest_compact,base) save_json(manifest_full_loc,manifest_full) + os.remove(manifest_compact_loc) +def backup_manifest(): + CUR_DIR=os.path.dirname(os.path.abspath(__file__)) + PACKAGE_DIR = os.path.join(CUR_DIR, "packages") + for conf_file in glob.glob(os.path.join(PACKAGE_DIR, '*')): + base = os.path.basename(conf_file) + if base not in ['README.md', 'TEMPLATE']: + # Check if "template" is in manifest.json + manifest_loc=os.path.join(conf_file, 'manifest.json') + with open(manifest_loc, 'r') as f: + contents = f.read() + if "template" in contents: + # Copy manifest.json to manifest.json.bak + manifest_loc_bak=os.path.join(conf_file, 'manifest.json.bak') + if os.path.exists(manifest_loc_bak): + os.remove(manifest_loc_bak) + os.rename(manifest_loc, manifest_loc_bak) + # Copy it to manifest_compact.json + manifest_loc_compact=os.path.join(conf_file, 'manifest_compact.json') + if os.path.exists(manifest_loc_compact): + os.remove(manifest_loc_compact) + shutil.copy(manifest_loc_bak, manifest_loc_compact) - - - diff --git a/planutils/package_installation.py b/planutils/package_installation.py index ea93cc4..eed3fac 100644 --- a/planutils/package_installation.py +++ b/planutils/package_installation.py @@ -10,7 +10,6 @@ CUR_DIR = os.path.dirname(os.path.abspath(__file__)) -manifest_converter.generate_manifest() def check_package(target, manifest): assert os.path.exists(manifest), "Error: Manifest must be defined for %s" % target diff --git a/planutils/settings.py b/planutils/settings.py index 3132097..9f4ad37 100644 --- a/planutils/settings.py +++ b/planutils/settings.py @@ -1,6 +1,8 @@ import json, os +from planutils import manifest_converter + # This should eventually be changed once the prefix is customizable PLANUTILS_PREFIX = os.path.join(os.path.expanduser('~'), '.planutils') @@ -14,3 +16,4 @@ def load(): def save(s): with open(SETTINGS_FILE, 'w') as f: f.write(json.dumps(s)) + manifest_converter.generate_manifest() From f99ae4bb926eb4239a3995d9b6dba171cd53a94a Mon Sep 17 00:00:00 2001 From: Christian Muise Date: Wed, 4 May 2022 09:37:27 -0400 Subject: [PATCH 3/5] Bringing the manifest expansion into the save functionality. --- planutils/__init__.py | 2 -- planutils/manifest_converter.py | 26 +++++--------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/planutils/__init__.py b/planutils/__init__.py index d1f616d..8a9a130 100644 --- a/planutils/__init__.py +++ b/planutils/__init__.py @@ -3,7 +3,6 @@ from pathlib import Path from planutils import settings -from planutils import manifest_converter from planutils.package_installation import PACKAGES @@ -14,7 +13,6 @@ def minimal_setup(): print(f"Creating {planutils_dir}...") planutils_dir.mkdir() os.symlink(script_dir / "packages", planutils_dir / "packages") - manifest_converter.backup_manifest() settings.save({'installed': []}) diff --git a/planutils/manifest_converter.py b/planutils/manifest_converter.py index d671a18..45e15d2 100644 --- a/planutils/manifest_converter.py +++ b/planutils/manifest_converter.py @@ -55,33 +55,17 @@ def generate_manifest(): for conf_file in glob.glob(os.path.join(PACKAGE_DIR, '*')): base = os.path.basename(conf_file) if base not in ['README.md', 'TEMPLATE']: - manifest_compact_loc=os.path.join(conf_file, 'manifest_compact.json') - manifest_full_loc=os.path.join(conf_file, 'manifest.json') - if os.path.exists(manifest_compact_loc): - manifest_compact=load_json(manifest_compact_loc) - manifest_full=generate_full_manifest(service_templates,manifest_compact,base) - save_json(manifest_full_loc,manifest_full) - os.remove(manifest_compact_loc) - -def backup_manifest(): - CUR_DIR=os.path.dirname(os.path.abspath(__file__)) - PACKAGE_DIR = os.path.join(CUR_DIR, "packages") - for conf_file in glob.glob(os.path.join(PACKAGE_DIR, '*')): - base = os.path.basename(conf_file) - if base not in ['README.md', 'TEMPLATE']: + manifest_loc=os.path.join(conf_file, 'manifest.json') # Check if "template" is in manifest.json manifest_loc=os.path.join(conf_file, 'manifest.json') with open(manifest_loc, 'r') as f: contents = f.read() if "template" in contents: - # Copy manifest.json to manifest.json.bak manifest_loc_bak=os.path.join(conf_file, 'manifest.json.bak') if os.path.exists(manifest_loc_bak): os.remove(manifest_loc_bak) - os.rename(manifest_loc, manifest_loc_bak) - # Copy it to manifest_compact.json - manifest_loc_compact=os.path.join(conf_file, 'manifest_compact.json') - if os.path.exists(manifest_loc_compact): - os.remove(manifest_loc_compact) - shutil.copy(manifest_loc_bak, manifest_loc_compact) + shutil.copy(manifest_loc, manifest_loc_bak) + manifest_compact=load_json(manifest_loc) + manifest_full=generate_full_manifest(service_templates,manifest_compact,base) + save_json(manifest_loc,manifest_full) From 9a9f27b383f9c11c7abcf308dfd6be711ff775da Mon Sep 17 00:00:00 2001 From: Christian Muise Date: Wed, 4 May 2022 10:06:59 -0400 Subject: [PATCH 4/5] Moving back to regular manifest. --- .../cerberus-sat/{manifest_compact.json => manifest.json} | 0 planutils/packages/delfi/{manifest_compact.json => manifest.json} | 0 .../dual-bfws-fdparser/{manifest_compact.json => manifest.json} | 0 .../dual-bfws-ffparser/{manifest_compact.json => manifest.json} | 0 .../packages/enhsp-2020/{manifest_compact.json => manifest.json} | 0 .../forbiditerative-topk/{manifest_compact.json => manifest.json} | 0 planutils/packages/kstar/{manifest_compact.json => manifest.json} | 0 .../packages/lama-first/{manifest_compact.json => manifest.json} | 0 planutils/packages/lama/{manifest_compact.json => manifest.json} | 0 planutils/packages/lapkt/{manifest_compact.json => manifest.json} | 0 planutils/packages/optic/{manifest_compact.json => manifest.json} | 0 planutils/packages/tfd/{manifest_compact.json => manifest.json} | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename planutils/packages/cerberus-sat/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/delfi/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/dual-bfws-fdparser/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/dual-bfws-ffparser/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/enhsp-2020/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/forbiditerative-topk/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/kstar/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/lama-first/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/lama/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/lapkt/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/optic/{manifest_compact.json => manifest.json} (100%) rename planutils/packages/tfd/{manifest_compact.json => manifest.json} (100%) diff --git a/planutils/packages/cerberus-sat/manifest_compact.json b/planutils/packages/cerberus-sat/manifest.json similarity index 100% rename from planutils/packages/cerberus-sat/manifest_compact.json rename to planutils/packages/cerberus-sat/manifest.json diff --git a/planutils/packages/delfi/manifest_compact.json b/planutils/packages/delfi/manifest.json similarity index 100% rename from planutils/packages/delfi/manifest_compact.json rename to planutils/packages/delfi/manifest.json diff --git a/planutils/packages/dual-bfws-fdparser/manifest_compact.json b/planutils/packages/dual-bfws-fdparser/manifest.json similarity index 100% rename from planutils/packages/dual-bfws-fdparser/manifest_compact.json rename to planutils/packages/dual-bfws-fdparser/manifest.json diff --git a/planutils/packages/dual-bfws-ffparser/manifest_compact.json b/planutils/packages/dual-bfws-ffparser/manifest.json similarity index 100% rename from planutils/packages/dual-bfws-ffparser/manifest_compact.json rename to planutils/packages/dual-bfws-ffparser/manifest.json diff --git a/planutils/packages/enhsp-2020/manifest_compact.json b/planutils/packages/enhsp-2020/manifest.json similarity index 100% rename from planutils/packages/enhsp-2020/manifest_compact.json rename to planutils/packages/enhsp-2020/manifest.json diff --git a/planutils/packages/forbiditerative-topk/manifest_compact.json b/planutils/packages/forbiditerative-topk/manifest.json similarity index 100% rename from planutils/packages/forbiditerative-topk/manifest_compact.json rename to planutils/packages/forbiditerative-topk/manifest.json diff --git a/planutils/packages/kstar/manifest_compact.json b/planutils/packages/kstar/manifest.json similarity index 100% rename from planutils/packages/kstar/manifest_compact.json rename to planutils/packages/kstar/manifest.json diff --git a/planutils/packages/lama-first/manifest_compact.json b/planutils/packages/lama-first/manifest.json similarity index 100% rename from planutils/packages/lama-first/manifest_compact.json rename to planutils/packages/lama-first/manifest.json diff --git a/planutils/packages/lama/manifest_compact.json b/planutils/packages/lama/manifest.json similarity index 100% rename from planutils/packages/lama/manifest_compact.json rename to planutils/packages/lama/manifest.json diff --git a/planutils/packages/lapkt/manifest_compact.json b/planutils/packages/lapkt/manifest.json similarity index 100% rename from planutils/packages/lapkt/manifest_compact.json rename to planutils/packages/lapkt/manifest.json diff --git a/planutils/packages/optic/manifest_compact.json b/planutils/packages/optic/manifest.json similarity index 100% rename from planutils/packages/optic/manifest_compact.json rename to planutils/packages/optic/manifest.json diff --git a/planutils/packages/tfd/manifest_compact.json b/planutils/packages/tfd/manifest.json similarity index 100% rename from planutils/packages/tfd/manifest_compact.json rename to planutils/packages/tfd/manifest.json From 5e8ba380b32c92f657050feb5e5ae4931a88d886 Mon Sep 17 00:00:00 2001 From: Christian Muise Date: Thu, 5 May 2022 22:51:44 -0400 Subject: [PATCH 5/5] Update planutils/manifest_converter.py --- planutils/manifest_converter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/planutils/manifest_converter.py b/planutils/manifest_converter.py index 45e15d2..60000c1 100644 --- a/planutils/manifest_converter.py +++ b/planutils/manifest_converter.py @@ -57,7 +57,6 @@ def generate_manifest(): if base not in ['README.md', 'TEMPLATE']: manifest_loc=os.path.join(conf_file, 'manifest.json') # Check if "template" is in manifest.json - manifest_loc=os.path.join(conf_file, 'manifest.json') with open(manifest_loc, 'r') as f: contents = f.read() if "template" in contents: