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

Laboratory name is always used as a path #167

Closed
aidanheerdegen opened this issue Feb 14, 2019 · 13 comments
Closed

Laboratory name is always used as a path #167

aidanheerdegen opened this issue Feb 14, 2019 · 13 comments
Labels

Comments

@aidanheerdegen
Copy link
Collaborator

I thought I could set laboratory name, without a path, and that would allow a config to be shared without a hard coded path. I formed that belief based on this code block:

https://github.com/marshallward/payu/blob/master/payu/laboratory.py#L65-L69

That code is never reached, as this logic:

https://github.com/marshallward/payu/blob/master/payu/laboratory.py#L40-L44

means it isn't called, even if laboratory isn't a full path.

@aidanheerdegen
Copy link
Collaborator Author

I've "fixed" it by changing the logic to this:

        # If no lab path is set, generate a default path
        if not self.basepath or not os.path.isabs(self.basepath):
            self.basepath = self.get_default_lab_path(config)

should I then remove the isabs test in get_default_lab_path? Seems redundant now.

@marshallward
Copy link
Collaborator

So laboratory: some/rel/path is not working? that is the issue?

I'm confused because set_default_lab_path should not even be called if laboratory: ... is set.

@aidanheerdegen
Copy link
Collaborator Author

I want to be able to have this:

laboratory: access-esm
model: access

So when I share this config it will make a /short/$PROJECT/$USER/access-esm laboratory

@aidanheerdegen
Copy link
Collaborator Author

The code seems to suggest this is possible

@marshallward
Copy link
Collaborator

i think it's just not handled, i.e. a bug.

Maybe just convert laboratory: access-esm to an absolute path? set_default_lab_path is really supposed to be for when no lab is set.

@marshallward
Copy link
Collaborator

This seems equally relevant to PAYU_LAB_PATH, btw

@marshallward
Copy link
Collaborator

Seems like this whole block is presuming absolute paths (if that is the problem, still not clear):

        if lab_path:
            self.basepath = lab_path
        elif 'PAYU_LAB_PATH' in os.environ:
            self.basepath = os.environ.get('PAYU_LAB_PATH')
        else:
            self.basepath = config.get('laboratory')

maybe save to a temp variable then conditionally convert it to absolute path before saving to self.basepath

@marshallward
Copy link
Collaborator

Either way, I would not recommend calling set_default_lab_path if config['laboratory'] is set.

@aidanheerdegen
Copy link
Collaborator Author

So why does this check even exist?

        if os.path.isabs(lab_name):
            lab_path = lab_name
        else:
            user_name = config.get('user', default_user)
            lab_path = os.path.join(short_path, user_name, lab_name)

@aidanheerdegen
Copy link
Collaborator Author

That is literally what I want to do, but am prevented by the code above

@aidanheerdegen
Copy link
Collaborator Author

In a way, you can use the way the code currently works to sort of have what @nichannah would like, and make the laboratory local. I know, he doesn't want all the symlinks, but it is 70% of what he wants.

What I am suggesting would require something like

laboratory: ./local

to have a local laboratory

@aidanheerdegen
Copy link
Collaborator Author

I think what I am suggesting would make it behave the same way as input paths, absolute paths are respected, otherwise relative to the input dir.

I don't see why laboratory is an exception.

@aidanheerdegen
Copy link
Collaborator Author

Agreed that relative laboratory paths should be supported. Implemented here

https://github.com/marshallward/payu/pull/166

Will close this as a result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants