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

Issues with mixer.SKIP #122

Open
multimeric opened this issue Aug 13, 2019 · 1 comment
Open

Issues with mixer.SKIP #122

multimeric opened this issue Aug 13, 2019 · 1 comment

Comments

@multimeric
Copy link

I noticed in the tests, and the source code, that there is a mixer.SKIP property that can be used to skip the generation of certain fields:

mixer/tests/test_main.py

Lines 287 to 291 in 6af15d5

def test_skip():
mixer = Mixer()
test = mixer.blend(Test, one=mixer.SKIP)
assert test.one is not mixer.SKIP
assert test.one is int
.

My first question is, why is this not documented? It seems to be tested so it must work for normal use.

My second question involves using SKIP with the SQLAlchemy backend. I've noticed if you try to use these together, you'll get an error:

# I think the model you use here can be anything that has a relationship field
x = mix.blend(models.ReportMeta, report_meta_key='key_1', report_meta_value='1', report=mix.SKIP)

And you get:

Traceback (most recent call last):
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/mixer/main.py", line 568, in blend
    return type_mixer.blend(**values)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/mixer/main.py", line 140, in blend
    target = self.postprocess(target, postprocess_values)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/mixer/backend/sqlalchemy.py", line 76, in postprocess
    setattr(target, name, value)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 262, in __set__
    instance_state(instance), instance_dict(instance), value, None
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 975, in set
    value = self.fire_replace_event(state, dict_, value, old, initiator)
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 998, in fire_replace_event
    state, value, previous, initiator or self._replace_token
  File "/home/michael/Programming/MegaQC/venv/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 1407, in emit_backref_from_scalar_set_event
    instance_state(child),
AttributeError: Mixer (<class 'megaqc.model.models.ReportMeta'>): 'object' object has no attribute '_sa_instance_state'

I assume this is a bug?

@mcbloch
Copy link
Contributor

mcbloch commented Mar 1, 2021

I'll up the fact that it not being documented was a real struggle.

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

No branches or pull requests

2 participants