-
Notifications
You must be signed in to change notification settings - Fork 33
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
Newbie question: how to run py2puml in certain hierarchy? #21
Comments
Hello @Highlander1970, any questions are ok to ask 😃 Given the folder names you gave as an example, I assume the
Assuming that you either have installed cd C:\Folder_A\Folder_AA
py2puml Folder_Project Folder_Project Do these commands output what you expect? |
I am so confused too. The root of my Python project is the root of my git repo (the repo I'm looking doesn't do a deeper hierarchy than that). No matter what I do I either get empty UML or I get a Can you give an example for this use case? Perhaps, there needs some verbose output in these cases to explain how the parameters are interpreted and how the resolution is done. |
hi @huyz, I am sorry that it is difficult for you to use It is not a good practice to have your python files directly at the root of your git project (see my previous answer and its link). As you can see in this https://github.com/huyz/flask-api repository that you forked, all the flask API code lies in the So if your project contains a single python file, cd git_project_folder
py2puml example_library example_library And you would be able to run your script like this: cd git_project_folder
python -m example_library
# example_library is a folder in this case, but the python interpreter will look for a __main__.py file to execute
# or
python example_library/__main__.py |
This is a work project. So I can't post it. (And I can't easily change the hierarchy, right now). But how would you invoke |
hello @huyz
Is it the error you are facing? Producing puml documentation for a root file ( |
Yes that's the error. This is why I'm confused |
Not working for me too. :| |
hello @basilmusa I am sorry to read that the library does not work for you neither. Can you detail what your setup is (project structure, folders and files, the commands you tried), so that I can reproduce and investigate, if you please? |
I'm experiencing the same error as @huyz and @basilmusa when attempting to run
Can |
@ColtAllen: some answers to your different questions:
But |
@lucsorel This issue crossed my mind again recently, and after looking through the Plant UML documentation, I think my problem is caused by the lack of class objects in the Python modules I'm using. Classes tend to be overkill for a lot of ML pipelines, but if PlantUML does not support the illustration of Python methods and the dependencies between them, I don't think this will be a viable documentation solution for any of my projects. |
hello @ColtAllen Indeed, |
hi @Highlander1970 @huyz @basilmusa 🙂 Please, forgive me for the long delay before solving this issue. It took me a while to understand how Python imports modules, specifically that Python uses the pathes listed in ❓ Would anyone of you be kind enough to review and approve #40 which fixes this issue, if you please? 🙏 The fix was short (see https://github.com/lucsorel/py2puml/pull/40/files#diff-7ff32e929e86cd812f60d9666a605c5b3d0a6cf13e938a4767ff538064e2b6c3R12) and a unit test checks that (https://github.com/lucsorel/py2puml/pull/40/files#diff-241c03bb18920b9ecd1bf42fd72007a92a4e08e44c95009d340ffb1fd0c3627dR31-R44). As a maintainer, I appreciate to have the feedback of users (aside from adding issues 😉). If you can't or don't have time, just let me know and I will validate the pull request myself. You can test the fix on @huyz 's test project (https://github.com/huyz/py2puml-test): git clone git@github.com:huyz/py2puml-test.git
cd py2puml-test
# assuming python3 below
python -m venv .venv
source .venv/bin/activate
pip install py2puml==0.7.1
py2puml project project
# -> this fails with "ModuleNotFoundError: No module named 'project'" Then, modify #!/usr/bin/env python
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
from pathlib import Path
from sys import path
from py2puml.py2puml import py2puml
def run():
# adds the current working directory to the system path so that py2puml can import them
current_working_directory = str(Path.cwd().resolve())
if current_working_directory not in path:
path.append(current_working_directory)
argparser = ArgumentParser(description='Generate PlantUML class diagrams to document your Python application.')
argparser.add_argument('-v', '--version', action='version', version='py2puml 0.7.1')
argparser.add_argument('path', metavar='path', type=str, help='the filepath to the domain')
argparser.add_argument('module', metavar='module', type=str, help='the module name of the domain', default=None)
args = argparser.parse_args()
print(''.join(py2puml(args.path, args.module))) Then running @startuml project
namespace project.__main__ {}
class project.__main__.App {
}
footer Generated by //py2puml//
@enduml |
@ColtAllen your participation on this issue was not really related to the pull request; but you are welcome for review or approval, if you like 🙏 🙂 |
I was able to get 0.7.2 to work on my simple example. It's going to be a while until I can try it out on another full-blown project as I'm no longer working in Python at the moment. Thanks for the fixes. |
I humbly apologize for an absolute newbie question, but I seem to be unable to get py2puml to produce any usable result (apart from empty "@startuml/@enduml"):
As a work in progress, I have following file structure:
C:\Folder_A\Folder_AA\Folder_Project\module1.py
C:\Folder_A\Folder_AA\Folder_Project\module2.py
C:\Folder_A\Folder_AA\Folder_Project\subfolder\module3.py
What am I to enter into path and module parameters to get an output of all classes used in all three modules?
The text was updated successfully, but these errors were encountered: