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 zip_lists filter to yacfg | Improve and cleanup the github actions #316

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rvais
Copy link

@rvais rvais commented Apr 18, 2024

Fixes/Improves:
In theory it should unify and fix the github actions steps. Should make sure that changes to the yacfg don't break anything.

Proposed Changes (What, How, and Why):
Adds zip_lists function because it can be useful in templates and I need that for one of the templates I've created.
Should create tuples/pairs of objects from two lists. It is useful when you don't want to explicitly declare relationship between or duplicate data of objects, that need to be paired. Uses underlying python zip function with minor input check.

@rvais
Copy link
Author

rvais commented Apr 18, 2024

Do not merge yet.

@rvais rvais requested review from jiridanek, michalxo and tlbueno April 18, 2024 10:26
@@ -136,6 +136,11 @@ def override_value_map_keys(value: Dict[str, Any]) -> Dict[str, Any]:
"""
return {override_value(key, key): val for key, val in value.items()}

def zip_lists(value: List[Any], pairing: List[Any]) -> List[(Any, Any)]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the invalid syntax for tuple types we discussed last week?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. It currently runs for me. Will check to make sure and resolve this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> from typing import List, Any
>>> List[(Any, Any)]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.12/typing.py", line 384, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/typing.py", line 1436, in __getitem__
    _check_generic(self, params, self._nparams)
  File "/usr/lib64/python3.12/typing.py", line 304, in _check_generic
    raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments for {cls};"
TypeError: Too many arguments for typing.List; actual 2, expected 1

@jiridanek
Copy link
Contributor

What about 1. Merging the gha changes in separate pr? And 2. Make PR and commit Workflows be single file triggered in both cases, and put conditional for the publish job thing only? That way less duplication.

def zip_lists(value: List[Any], pairing: List[Any]) -> List[(Any, Any)]:
if not isinstance(value, List) or not isinstance(pairing, List):
return []
return zip(value, pairing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a test/usage example for this. Having the actual template this will operate on only in a separate repo sucks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and will try to add the test into profile_test.sh.

@michalxo michalxo marked this pull request as draft April 18, 2024 10:38
@rvais
Copy link
Author

rvais commented Apr 18, 2024

What about 1. Merging the gha changes in separate pr? And 2. Make PR and commit Workflows be single file triggered in both cases, and put conditional for the publish job thing only? That way less duplication.

Make sense to do so. I am not familiar with the github actions enough to do the conditionals properly. Will look into it.

@jiridanek
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

2 participants