Comments (3)
The CLI mutates the $BEAMLINE
environment variable to keep the mappings between the beamline name and the module name consistent. For example if a user types dodal connect s03
, dodal knows it must use the i03
module, but the i03
module depends on $BEAMLINE
being s03
to connect to the s03
PVs.
We need to find a cleaner way of doing this that doesn't force us to keep the CLI argument and the environment variable in sync.
May be related to #502, as a solution to that could supersede the $BEAMLINE
variable.
Another possible solution is to have a BEAMLINE
global that is informed by the CLI argument if supplied, and the environment variable if not, and have that passed universally to all parts of the code including the beamline module.
from dodal.
Setting
os.environ["BEAMLINE"]
caused unintended side effects
Can you elaborate on the side effects? In general though I agree that forcing the CLI arg and the env variable to be in sync is messy so happy to look for a better way.
from dodal.
The main one I saw was when I called it in the tests, it could change the behaviour of other tests that called code that read ${BEAMLINE}
, for example:
dodal/tests/unit_tests/test_log.py
Line 88 in 4f13765
I had to make sure os.environ
was patched for every CLI test, which is a reasonable solution, but as you say it is messy and generally good practice to avoid mutating global state because things like that pop up and can be hard to diagnose.
from dodal.
Related Issues (20)
- Update copier template to include SLF001
- Decide what to do about B008 HOT 1
- Clean up aperture scatterguard interface
- Move Training Rig Devices into Dodal
- Save panda should ignore DATA PV'S
- Transfocator: Convert to ophyd-async
- Draw crosshairs with better contrast
- Repo chores - are some issues outdated?
- Generic way to deal with devices that have different behaviour when there is no beam HOT 3
- Pressure jump devices collected updates
- Support J and K beamline prefixes
- PMAC ProgramRunner should first wait for status to change
- Come up with a system for beamline specific zebra constants
- Pydantic 2 refuses to deserialise PosixPath as Path object HOT 1
- Remove alias for DetectorParams.override_run_number HOT 2
- Linting failing on main
- Expose help and docs from device factory functions. HOT 2
- Unpin pyright version
- Read aperture/scatterguard hardware on read HOT 4
- Convert PMAC ProgramRunner to instead use kickoff and complete
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dodal.