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

Bug fixes #55

Merged
merged 6 commits into from
Sep 1, 2021
Merged

Bug fixes #55

merged 6 commits into from
Sep 1, 2021

Conversation

richardreeve
Copy link
Member

@richardreeve richardreeve commented Aug 31, 2021

Bugfixes:

@richardreeve
Copy link
Member Author

@soniamitchell - can you try running this to make sure you can still import (--using) and export (--export) init yamls, because I couldn't get them to work, so I did this "fix". My python may not be great though, so I'd appreciate a practical view on whether it works!

Copy link

@soniamitchell soniamitchell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! 👍

@soniamitchell
Copy link

I need this merged with dev to test run --ci

@kzscisoft kzscisoft self-requested a review September 1, 2021 09:14
fair/session.py Outdated
# Populate file type table
_local_uri = fdp_conf.get_local_uri()
_local_uri = self._global_config['registries']['local']['uri']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask why have you changed this line? The function get_local_uri does this anyway, but also catches the exception to print it in the same style as all errors in the CLI (hides the traceback unless --debug is used) and ensures it can be called from anywhere. Using a global function is better than hardcoding as it means should the layout of things change, only one place has to be altered.

def get_local_uri() -> str:
    _cfg = read_global_fdpconfig()
    try:
        return _cfg['registries']['local']['uri']
    except KeyError:
        raise fdp_exc.CLIConfigurationError(
            f"Expected key 'registries:local:uri' in local CLI configuration"
        )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't do the same actually - I suspect because get_local_uri() relies on read_global_fdpconfig() which relies on the file being written rather than being in memory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kzscisoft - I totally agree this is inelegant btw, happy to have a fix, but I just don't think it can involve get_local_uri()...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't do the same actually - I suspect because get_local_uri() relies on read_global_fdpconfig() which relies on the file being written rather than being in memory?

Hmm but is written a couple of lines above:

with open(fdp_com.global_fdpconfig(), "w") as f:
            yaml.dump(self._global_config, f)

Is this write failing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may seem a bit weird to re-read the same thing, but it is a failsafe in a way in that it tests the write actually did happen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah. Well, that's weird. It works now. I suspect that the file wasn't getting written out correctly because it was looking for a description key somewhere, and I got rid of that requirement - when I looked the file existed but was empty, so I assumed that it was part way through writing for some reason. Anyway, I'll happily undo this change then.

README.md Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Sep 1, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kzscisoft kzscisoft merged commit 462c23a into dev Sep 1, 2021
richardreeve added a commit that referenced this pull request Sep 1, 2021
richardreeve added a commit that referenced this pull request Sep 1, 2021
@richardreeve richardreeve deleted the rr/fixes branch September 14, 2021 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants