-
Notifications
You must be signed in to change notification settings - Fork 23
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
Restructure the minimal examples section [DOC-144] #200
Restructure the minimal examples section [DOC-144] #200
Conversation
93cbb86
to
68e20f3
Compare
60ee7db
to
1b3fbb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't agree with the suggestions I'll change my review to approved ;)
(you can batch all the changes you would like in a single commit btw)
docs/Minimal_examples.rst
Outdated
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
examples/frameworks/index | ||
examples/distributed/index | ||
examples/good_practices/index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this go in doc/index.rst
instead so we can see all of the sections from the home page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting idea, I'll try it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unable to make this work locally. Perhaps I'm doing something wrong. Did you mean to remove the toctree here instead have something like this in the index.rst
?
.. toctree::
:caption: Minimal Examples
:maxdepth: 2
Minimal_examples
examples/frameworks/index
examples/distributed/index
examples/good_practices/index
If so, this doesn't seem to work correctly, there is still only "Minimal Examples" under the "MINIMAL EXAMPLES" section in the left navbar.
Perhaps we could check this out together sometime this week if you don't mind? (I'm pretty bad at this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh also: I think that using .. include
would make them all end up in the same page, right? (Not sure if that would be part of the potential solution, but I wouldn't want that to happen here with the examples)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0f5ddd0
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Co-authored-by: satyaog <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
10c220b
to
f3d940c
Compare
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
docs/examples/preprocess.py
Outdated
elif line.startswith(".. literalinclude:: ") or not line: | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit brittle as a way to figure out where the block ends, compared to simply checking if the (non-stripped) line starts with a non-space character.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4bc0bae
generate_diff distributed/single_gpu/job.sh distributed/multi_gpu/job.sh | ||
generate_diff distributed/single_gpu/main.py distributed/multi_gpu/main.py | ||
|
||
# multi_gpu -> multi_node | ||
generate_diff distributed/002_multi_gpu/job.sh distributed/003_multi_node/job.sh | ||
generate_diff distributed/002_multi_gpu/main.py distributed/003_multi_node/main.py | ||
generate_diff distributed/multi_gpu/job.sh distributed/multi_node/job.sh | ||
generate_diff distributed/multi_gpu/main.py distributed/multi_node/main.py | ||
|
||
# single_gpu -> checkpointing | ||
generate_diff distributed/001_single_gpu/job.sh good_practices/checkpointing/job.sh | ||
generate_diff distributed/001_single_gpu/main.py good_practices/checkpointing/main.py | ||
generate_diff distributed/single_gpu/job.sh good_practices/checkpointing/job.sh | ||
generate_diff distributed/single_gpu/main.py good_practices/checkpointing/main.py | ||
|
||
# single_gpu -> hpo_with_orion | ||
generate_diff distributed/001_single_gpu/job.sh good_practices/hpo_with_orion/job.sh | ||
generate_diff distributed/001_single_gpu/main.py good_practices/hpo_with_orion/main.py | ||
generate_diff distributed/single_gpu/job.sh good_practices/hpo_with_orion/job.sh | ||
generate_diff distributed/single_gpu/main.py good_practices/hpo_with_orion/main.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we loop over **/job.sh
and **/main.py
instead, so we don't have to remember to update this file whenever we add a new example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I don't understand, but here we need to define the from-to relationship between examples. How do you suggest we do that automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah I had a brain fart here, sorry.
Although, one way to do this automatically would be to represent the examples as a Git arborescence: you write the code for single_gpu, then you create a multi_gpu branch that has one commit that is the difference, and so on, each example being its own branch. Then you can run a series of checkouts and cp to populate the examples directory in the actual docs repo. With this method you can also update the whole set of examples more easily by changing the base and looping on git rebase. But in any case this is out of scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's interesting!
I also played around with the idea of us editing the .diff files directly instead of the example files, and re-generating the derived examples if something changes in the base.
For now, with this limited number example dependencies, it's pretty manageable to make a change in the base example and then copy-paste it to the 5-6 derived examples. However there is potentially a better solution in the long run for sure.
I agree with you, I don't think it's worth it to spend too much time working on that right now.
docs/examples/preprocess.py
Outdated
f" {_l}".rstrip(" ") | ||
for _l in (docs_root / path).read_text().split("\n") | ||
] | ||
content_lines = content_lines[:i] + insert + content_lines[i + 1 :] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This drops content_lines[i]
, is this what we want? We already removed the literalinclude lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4bc0bae
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
71f5b94
to
cd154ff
Compare
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
docs/examples/preprocess.py
Outdated
def _get_block_length() -> int: | ||
length = 1 | ||
while ( | ||
line_index + length < len(content_lines) | ||
and content_lines[line_index + length] | ||
and not content_lines[line_index + length].isspace() | ||
): | ||
length += 1 | ||
return length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested so maybe I'm following the code wrong, but you only stop on empty/whitespace lines, so it seems to me that the function will return 4 on the following block:
.. literalinclude:: x.py
:language: python
.. important::
Don't run vscode on the login nodes you guys.
And 1 on this one, which I'm not certain is legal or not:
.. literalinclude:: x.py
:language: python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here: 806c59d
Signed-off-by: Fabrice Normandin <[email protected]>
Signed-off-by: Fabrice Normandin <[email protected]>
Les autres PR d'exemples minimalistes devraient être rebase sur ces changements (ou bien merge ces commits). Cette PR-là change un peu la structure de la section d'exemples minimalistes: