Git Product home page Git Product logo

Comments (3)

callumforrester avatar callumforrester commented on September 14, 2024

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.

DominicOram avatar DominicOram commented on September 14, 2024

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.

callumforrester avatar callumforrester commented on September 14, 2024

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:

def test_no_env_variable_sets_correct_file_handler(

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.