Closed gdubicki closed 1 year ago
Thanks for reporting this! Looks like the final tar file didn't include any nested folders. I rebuilt/published with 2.0.1
which should make everything work now.
Thanks, but 2.0.1 is not published in pypi: https://pypi.org/project/ez-yaml/
Wow, sorry I screwed this up twice. 2.0.1 is published now @gdubicki
Thanks, but now I have a different error:
ImportError: cannot import name 'ez_yaml' from 'ez_yaml' (/opt/hostedtoolcache/Python/3.7.17/x64/lib/python3.7/site-packages/ez_yaml/__init__.py)
See the full stack trace here.
Man I thought I messed up again, but this is actually intended!
Just replace from ez_yaml import ez_yaml
with import ez_yaml
and you should be good to go. @gdubicki
Just wanted to check back in on this, I'll reopen if its still an issue
Hey, sorry for a late reply. Yes, that import change has helped with original issue, but after doing that we had another problem, which you can see in the failed tests here: https://github.com/gitlabform/gitlabform/actions/runs/5975165001/job/16210621488
But I don't want to bother you with this anymore, we don't really need to update ez_yaml, our current version (1.2.0) works like a charm.
Thanks and have a nice day! :)
Glad to hear the old version works for you guys 👍
I'm confused by the test failures though, is ordereddict
a custom version of python's OrderedDict
?
ez_yaml.__dependencies__.ruamel.yaml.representer.RepresenterError: cannot represent an object: ordereddict([('config_version', 3), ('projects_and_groups', ordereddict([('gitlabform_group_disarray/gitlabform_project_gents', ordereddict([('project', ordereddict([('archive', True)]))]))]))])
I tried to recreate with python's order dict and couldn't reproduce
>>> from collections import OrderedDict
>>> import ez_yaml
>>> a = OrderedDict([
... (
... 'projects_and_groups', OrderedDict([
... (
... 'group/*', OrderedDict(
... [(
... 'merge_requests_approval_rules', {'legacy': {'approvals_required': 0, 'name': 'Approvers (configured using GitLabForm)'}}
... )]
... )
... ),
... (
... 'group/envs/qa', OrderedDict([
... (
... 'merge_requests_approvals', OrderedDict([
... (
... 'reset_approvals_on_push', False
... ),
... (
... 'disable_overriding_approvers_per_merge_request', True
... ),
... (
... 'merge_requests_author_approval', False
... )
... ])
... ),
... (
... 'merge_requests_approval_rules', {'legacy': {'approvals_required': 2, 'name': 'Approvers (configured using GitLabForm)', 'users': ['user1', 'user2'], 'groups': ['some-group']}}
... )
... ])
... )
... ])
... )
... ])
KeyboardInterrupt
>>> print(ez_yaml.to_string(a))
!!omap
- projects_and_groups: !!omap
- group/*: !!omap
- merge_requests_approval_rules:
legacy:
approvals_required: 0
name: Approvers (configured using GitLabForm)
- group/envs/qa: !!omap
- merge_requests_approvals: !!omap
- reset_approvals_on_push: false
- disable_overriding_approvers_per_merge_request: true
- merge_requests_author_approval: false
- merge_requests_approval_rules:
legacy:
approvals_required: 2
name: Approvers (configured using GitLabForm)
users:
- user1
- user2
groups:
- some-group
In retrospect it was a bad idea to add a link to tests output instead of a copy of the error here - the logs are not available anymore and I don't remember what the error was, exactly. :P
Anyway, I still have a problem as I retried to use v2.2.0 of ez_yaml.
The error is:
> gitlabform = get_gitlabform(config=config_yaml, target=target)
tests/unit/test_target_all_defined.py:19:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/unit/__init__.py:22: in get_gitlabform
gf = GitLabForm(
gitlabform/__init__.py:112: in __init__
self.gitlab, self.configuration = self._initialize_configuration_and_gitlab()
gitlabform/__init__.py:352: in _initialize_configuration_and_gitlab
configuration_transformers.transform(configuration)
gitlabform/configuration/transform.py:38: in transform
config_before = ez_yaml.to_string(obj=configuration.config, options={})
venv/lib/python3.12/site-packages/ez_yaml/__init__.py:53: in to_string
yaml.dump(obj, string_stream, **options)
venv/lib/python3.12/site-packages/ez_yaml/__dependencies__/ruamel/yaml/main.py:595: in dump
return self.dump_all([data], stream, transform=transform)
venv/lib/python3.12/site-packages/ez_yaml/__dependencies__/ruamel/yaml/main.py:604: in dump_all
self._context_manager.dump(data)
venv/lib/python3.12/site-packages/ez_yaml/__dependencies__/ruamel/yaml/main.py:940: in dump
self._yaml.representer.represent(data)
venv/lib/python3.12/site-packages/ez_yaml/__dependencies__/ruamel/yaml/representer.py:80: in represent
node = self.represent_data(data)
venv/lib/python3.12/site-packages/ez_yaml/__dependencies__/ruamel/yaml/representer.py:122: in represent_data
raise error
venv/lib/python3.12/site-packages/ez_yaml/__dependencies__/ruamel/yaml/representer.py:114: in represent_data
node = self.yaml_representers[None](self, data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ez_yaml.__dependencies__.ruamel.yaml.representer.RoundTripRepresenter object at 0x106783200>
data = ordereddict({'config_version': 3, 'gitlab': ordereddict({'url': 'https://gitlab.com', 'token': 'foobar'}), 'projects_a...ojects/*': ordereddict({'foobar': 'barfoo'}), 'group_and_all_its_descendants/**': ordereddict({'barfoo': 'foobar'})})})
def represent_undefined(self, data):
# type: (Any) -> None
> raise RepresenterError(_F('cannot represent an object: {data!s}', data=data))
E ez_yaml.__dependencies__.ruamel.yaml.representer.RepresenterError: cannot represent an object: ordereddict({'config_version': 3, 'gitlab': ordereddict({'url': 'https://gitlab.com', 'token': 'foobar'}), 'projects_and_groups': ordereddict({'group_only': ordereddict({'foo': 'bar'}), 'subgroup/only': ordereddict({'bar': 'foo'}), 'group_and_its_projects/*': ordereddict({'foobar': 'barfoo'}), 'group_and_all_its_descendants/**': ordereddict({'barfoo': 'foobar'})})})
I'm confused by the test failures though, is ordereddict a custom version of python's OrderedDict?
It seems to be a ruamel's thing, see https://github.com/pycontribs/ruamel-yaml/blob/4c1728aab0cd5c9bfc84cf1132b228074b783907/compat.py#L38.
Hi @jeff-hykin!
Sadly the latest version doesn't work if you import it f.e. in a virtualenv: