Skip to content

Fixes to factory to handle ignore_external.#293

Merged
TeresiaOlsson merged 2 commits into
mainfrom
factory-ignore-external
Jun 19, 2026
Merged

Fixes to factory to handle ignore_external.#293
TeresiaOlsson merged 2 commits into
mainfrom
factory-ignore-external

Conversation

@TeresiaOlsson

@TeresiaOlsson TeresiaOlsson commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This is to fix issue #292.

I have added so the factory returns None instead of building an object if ignore_external = True and the module isn't found.

I had to also add a fix in the linear magnet module to handle the case when the powerconverter becomes None.

@TeresiaOlsson TeresiaOlsson linked an issue Jun 18, 2026 that may be closed by this pull request
@TeresiaOlsson

Copy link
Copy Markdown
Contributor Author

The issue is now that sr.live just isn't created. Feels like it rather should be None. Or what do you think?

@JeanLucPons

Copy link
Copy Markdown
Contributor

Yes that's normal that sr.live is not created as the module is unknown but you can still use the rest such as sr.design.
This is the expected behavior.

@TeresiaOlsson

Copy link
Copy Markdown
Contributor Author

So you want this error if the user does sr.live?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[7], line 1
----> 1 sr.live

File ~/Documents/software/pyAML/pyaml/pyaml/accelerator.py:219, in Accelerator.live(self)
    209 @property
    210 def live(self) -> ControlSystem:
    211     """
    212     Get the live control system.
    213 
   (...)    217         The live control system instance
    218     """
--> 219     return self.__live

AttributeError: 'Accelerator' object has no attribute '_Accelerator__live'

I thought maybe it would be better to return None?

@JeanLucPons

Copy link
Copy Markdown
Contributor

Yes for me it is fine.

@TeresiaOlsson

Copy link
Copy Markdown
Contributor Author

Maybe it is just that:

        __design = None
        __live = None

Should be:

        self.__design = None
        self.__live = None

and the error will be gone.

@TeresiaOlsson

Copy link
Copy Markdown
Contributor Author

Yes, that would fix it. Unless there is a reason why those two attributes doesn't have self before?

@TeresiaOlsson TeresiaOlsson merged commit a24402e into main Jun 19, 2026
3 checks passed
@TeresiaOlsson TeresiaOlsson deleted the factory-ignore-external branch June 19, 2026 08:16
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.

Bug - factory using ignore-external

2 participants