Skip to content

Conversation

@cadenmyers13
Copy link
Contributor

No description provided.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

not quite, please see if you can figure it out. Don't guess, try and figure out the logic.

Also, need a CR at the end of the doc.yml. You can see this by reviewing your own PR.....

import os
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../../src'))
pathlib.Path.insert(0, os.path.abspath('../..'))
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't how you do it. Please try and figure out how to do it differently using pathlib.

check that the docs build locally before pushing so we don't use CI credits for debugging but only testing debugged code. Also, there is still an os.path in there .....

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe ask chatgpt what that old syntax is doing so you understand that, then read a bit about pathlib so you know hte background and then trh and figure out how to do it with pathlib (and in the end ask chatgpt how how it would do it)..... (giving away my secrets here...don't let chatgpt take over, but get help)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remember to also refactor these ../.. into ../../..

Copy link
Contributor

Choose a reason for hiding this comment

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

so we will keep sys.path, there is no pathlib replacement for that, it contains the list of directories the system looks in in to find executables, but os.path.abspath will go to str(Path('../..').resolve()) (but get the right number of parent directories so everything works. and I think we need the str())

Copy link
Collaborator

Choose a reason for hiding this comment

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

You still require sys.path as that gives the interpreter knowledge of where to look for modules. The update is to remove uses of os. Though generally fine to use, os handles paths as strings, while Pathlib creates a platform-specific object with some additional functionalities. Probably the most useful is glob if you have worked with the * operator on bash.

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

pls see inline

import os
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../../src'))
pathlib.Path.insert(0, os.path.abspath('../..'))
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe ask chatgpt what that old syntax is doing so you understand that, then read a bit about pathlib so you know hte background and then trh and figure out how to do it with pathlib (and in the end ask chatgpt how how it would do it)..... (giving away my secrets here...don't let chatgpt take over, but get help)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to refactor <../../tutorial/tutorialData.zip> to <../../../tutorial/tutorialData.zip>

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

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

another thought (please see inline) though I am not sure that this is actually needed at all or desirable.

import os
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../../src'))
pathlib.Path.insert(0, os.path.abspath('../..'))
Copy link
Contributor

Choose a reason for hiding this comment

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

so we will keep sys.path, there is no pathlib replacement for that, it contains the list of directories the system looks in in to find executables, but os.path.abspath will go to str(Path('../..').resolve()) (but get the right number of parent directories so everything works. and I think we need the str())

@cadenmyers13
Copy link
Contributor Author

@sbillinge I saw .parents[] in pathlib. Will this not work?

@Sparks29032
Copy link
Collaborator

Parents and resolve do different things. If x is a PosixPath (on Mac/Linux) or WindowsPath (on... Windows), then x.resolve() gives the absolute path (starting from root) as well as resolving symbolic links (which indeed makes it more general). What we have given to the program is a relative path as .. means the outer directory of this current directory. On the other hand x.parents returns a list of outer directories, and you would have to manually recombine all these directories to reconstruct the absolute path.

@sbillinge
Copy link
Contributor

sbillinge commented May 21, 2024 via email

@sbillinge
Copy link
Contributor

@cadenmyers13 thanks for this, great job!

For future reference, there is way too much on this PR. This would have been better as two or even three PRs. It is best to make multiple branches (off a fully synced main each time) and only do one thing on each PR. That makes things WAY easier to review and get merged. You can (should) have mulitple PRs open from different branches at any given time.

Also, only merge commits from other branches when absolutely necessary. If we design things right we can keep things of each branch sufficiently separated that they can be worked on independently. Not always, but as long as things are getting merged quickly (because they are small) we rarely run into problems (another reason to do small granular PRs)

I am not sure if everything is quite right on this, but if not we can open new PRs to fix any problems.

Thanks so much, great job! I know it is a steep learning curve!

Thanks again. I know it is a learning experience.

@sbillinge sbillinge merged commit 24bb5d1 into diffpy:main May 22, 2024
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.

3 participants