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

investigate inclusion package hash in PublicId.__eq__ comparison #449

Open
Karrenbelt opened this issue Nov 21, 2022 · 0 comments
Open

investigate inclusion package hash in PublicId.__eq__ comparison #449

Karrenbelt opened this issue Nov 21, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@Karrenbelt
Copy link

including the _package_hash will affect the functionality in the following 4 places.

  • eject

    open-aea/aea/cli/eject.py

    Lines 204 to 206 in 77474ff

    reverse_reachable_dependencies = reachable_nodes(
    reverse_dependencies, {package_id.without_hash()}
    )
  • remove

    open-aea/aea/cli/remove.py

    Lines 193 to 226 in 77474ff

    def get_item_dependencies_with_reverse_dependencies(
    self, item: PackageConfiguration, package_id: Optional[PackageId] = None
    ) -> Dict[PackageId, Set[PackageId]]:
    """
    Get item dependencies.
    It's recursive and provides all the sub dependencies.
    :param item: the item package configuration
    :param package_id: the package id.
    :return: dict with PackageId: and set of PackageIds that uses this package
    """
    result: defaultdict = defaultdict(set)
    for dep_package_id in self._get_item_requirements(
    item, self._ignore_non_vendor
    ):
    if package_id is None:
    _ = result[dep_package_id.without_hash()] # init default dict value
    else:
    result[dep_package_id.without_hash()].add(package_id.without_hash())
    if not self.is_present_in_agent_config(
    dep_package_id.without_hash()
    ): # pragma: nocover
    continue
    dep_item = self.get_item_config(dep_package_id)
    for item_key, deps in self.get_item_dependencies_with_reverse_dependencies(
    dep_item, dep_package_id
    ).items():
    result[item_key.without_hash()] = result[item_key].union(deps)
    return result
  • check_packages
    def _add_package_type(package_type: PackageType, public_id_str: str) -> PackageId:
    return PackageId(package_type, PublicId.from_str(public_id_str))
  • registry/add
    def fetch_package(obj_type: str, public_id: PublicId, cwd: str, dest: str) -> Path:
    """
    Fetch a package (connection/contract/protocol/skill) from Registry.
    :param obj_type: str type of object you want to fetch:
    'connection', 'protocol', 'skill'
    :param public_id: str public ID of object.
    :param cwd: str path to current working directory.
    :param dest: destination where to save package.
    :return: package path
    """
    logger.debug(
    "Fetching {obj_type} {public_id} from Registry...".format(
    public_id=public_id, obj_type=obj_type
    )
    )
    logger.debug(
    "Downloading {obj_type} {public_id}...".format(
    public_id=public_id, obj_type=obj_type
    )
    )
    package_meta = get_package_meta(obj_type, public_id)
    file_url = cast(str, package_meta["file"])
    filepath = download_file(file_url, cwd)
    # next code line is needed because the items are stored in tarball packages as folders
    dest = os.path.split(dest)[0]
    logger.debug(
    "Extracting {obj_type} {public_id}...".format(
    public_id=public_id, obj_type=obj_type
    )
    )
    extract(filepath, dest)
    logger.debug(
    "Successfully fetched {obj_type} '{public_id}'.".format(
    public_id=public_id, obj_type=obj_type
    )
    )
    package_path = os.path.join(dest, public_id.name)
    return Path(package_path)

original comment: #445 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants