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

Add essence-feature-usage-stats tool #31

Merged
merged 61 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1f81e3d
Add essence-feature-usage-stats tool
gskorokhod Oct 30, 2023
39fb6c7
Modified gitignore
gskorokhod Oct 30, 2023
07bd9a4
Remove pycache files
gskorokhod Oct 30, 2023
5ba0e0d
Automatically download conjure from repo, lint essence-feature-usage-…
gskorokhod Nov 1, 2023
557e076
Merge pull request #1 from conjure-cp/main
gskorokhod Nov 1, 2023
36e8232
Get conjure version (use in the future to avoid re-downloading conjur…
gskorokhod Nov 1, 2023
39b5b40
Merge remote-tracking branch 'origin/main'
gskorokhod Nov 1, 2023
88d6da7
Set up GH action to generate the html page
gskorokhod Nov 1, 2023
496cf70
Set up GH action to generate the html page - WIP
gskorokhod Nov 1, 2023
582dfd9
Set up GH action to generate the html page - WIP
gskorokhod Nov 1, 2023
bedb554
Update requirements.txt
gskorokhod Nov 1, 2023
11b6066
Working on CI - WIP
gskorokhod Nov 1, 2023
b6fd931
CI - WIP
gskorokhod Nov 1, 2023
d1cd45a
CI - WIP
gskorokhod Nov 1, 2023
d530926
Working on CI - WIP
gskorokhod Nov 1, 2023
7d0da09
Working on CI - WIP
gskorokhod Nov 1, 2023
8fe1f58
CI - WIP
gskorokhod Nov 1, 2023
59e6089
Working on CI - WIP
gskorokhod Nov 1, 2023
39feed8
Working on CI - WIP
gskorokhod Nov 1, 2023
9d49b5b
Working on CI - WIP
gskorokhod Nov 1, 2023
d33a7dc
Working on CI - WIP
gskorokhod Nov 1, 2023
4d8e7a6
Working on CI - WIP
gskorokhod Nov 1, 2023
0f4698a
Working on CI - WIP
gskorokhod Nov 1, 2023
d42e3f4
Working on CI - WIP
gskorokhod Nov 1, 2023
81190ac
Working on CI - WIP
gskorokhod Nov 1, 2023
7601396
Working on CI - WIP
gskorokhod Nov 1, 2023
a5d349b
Working on CI - WIP
gskorokhod Nov 1, 2023
6c9ba65
Working on CI - WIP
gskorokhod Nov 1, 2023
c2d25b4
Working on CI - WIP
gskorokhod Nov 1, 2023
9a14b34
CI - WIP
gskorokhod Nov 1, 2023
6e25867
Working on CI - WIP
gskorokhod Nov 1, 2023
46b579b
Working on CI - WIP
gskorokhod Nov 1, 2023
a9b2611
Working on CI - WIP
gskorokhod Nov 1, 2023
8fbfeb3
Working on CI - WIP
gskorokhod Nov 1, 2023
a6012ac
Working on CI - WIP
gskorokhod Nov 1, 2023
7d69e21
Working on CI - WIP
gskorokhod Nov 1, 2023
e259723
Working on CI - WIP
gskorokhod Nov 1, 2023
4f410fd
Working on CI - WIP
gskorokhod Nov 1, 2023
3106580
Working on CI - WIP
gskorokhod Nov 1, 2023
5c82afb
Working on CI - WIP
gskorokhod Nov 1, 2023
f185def
Working on CI - WIP
gskorokhod Nov 1, 2023
5eb01ea
Set up GitHub Pages CI
gskorokhod Nov 1, 2023
e0bb7ba
Set up GitHub Pages CI
gskorokhod Nov 1, 2023
9c915fd
TEMP: pages
gskorokhod Nov 1, 2023
9ca0372
mv pages to docs
gskorokhod Nov 1, 2023
79c9abf
Update essence-feature-stats.yml
gskorokhod Nov 2, 2023
411635b
Update essence-feature-stats.yml
gskorokhod Nov 2, 2023
4f91943
Update essence-feature-stats.yml
gskorokhod Nov 2, 2023
0aa886a
Remove unnecessary nav link
gskorokhod Nov 2, 2023
131e660
Remove docs folder and finalize the html page
gskorokhod Nov 2, 2023
9ee2a53
Add .nojekyll file
gskorokhod Nov 2, 2023
8137d1c
Make columns/rows hideable and add excluding / requiring certain keyw…
gskorokhod Nov 2, 2023
7e4dd6c
Merge remote-tracking branch 'origin/main'
gskorokhod Nov 2, 2023
2e4d67c
Update README.md
gskorokhod Nov 2, 2023
7df03e4
Update essence-feature-stats.yml
gskorokhod Nov 2, 2023
9e9ff18
Merge pull request #2 from conjure-cp/main
gskorokhod Nov 2, 2023
95b83f1
Remove .env file
gskorokhod Nov 2, 2023
5cdb63d
Update dependabot.yml
gskorokhod Nov 2, 2023
04424fa
Merge remote-tracking branch 'origin/main'
gskorokhod Nov 2, 2023
2264d8f
Update essence-feature-stats.yml
gskorokhod Nov 2, 2023
a422de1
Merge branch 'main' into main
ozgurakgun Nov 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
target

solvers/**/vendor/build
tools/essence-feature-usage-stats/.venv
Copy link
Contributor

Choose a reason for hiding this comment

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

.venv
pycache
.idea

tools/essence-feature-usage-stats/stats/__pycache__
tools/essence-feature-usage-stats/utils/__pycache__
tools/essence-feature-usage-stats/.idea
tools/essence-feature-usage-stats/test/__pycache__
tools/essence-feature-usage-stats/web/__pycache__

9 changes: 9 additions & 0 deletions tools/essence-feature-usage-stats/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ESSENCE_DIR=/home/mayday/Coding/VIP/EssenceCatalog
Copy link
Contributor

Choose a reason for hiding this comment

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

are these local paths still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the whole .env file is just for local testing. All the necessary env vars are in the GitHub Action

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove them from the repo then? As they are, they won't work on anybody else's computer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True! I have removed the file, just waiting for the CI to complete and the commit will appear here

CONJURE_DIR=/home/mayday/Coding/VIP/conjure-v2.5.0-linux-with-solvers
ESSENCE_EXAMPLES_REPO=https://github.com/conjure-cp/EssenceCatalog.git
KEYWORD_BLOCKLIST="mInfo,finds,givens,enumGivens,enumLettings,lettings,
unnameds,strategyQ,Auto,Interactive,strategyA,trailCompact,
nameGenState,nbExtraGivens,representations,representationsTree,
originalDomains,trailGeneralised,trailVerbose,trailRewrites,
mLanguage,language,version,mStatements,Name,Declaration,FindOrGiven,
SuchThat,Op"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tools/essence-feature-usage-stats/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tools/essence-feature-usage-stats/.idea/ruff.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tools/essence-feature-usage-stats/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

235 changes: 235 additions & 0 deletions tools/essence-feature-usage-stats/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions tools/essence-feature-usage-stats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# essence-feature-usage-stats

## About

This is an internal tool for the [conjure-oxide](https://github.com/conjure-cp/conjure-oxide) project.

It does the following:
- Given a directory containing Essence files, go through it and count how often every Essence language feature is used
- Display this data as a simple web page with a table

The purpose of this is to make it easier to find Essence examples to test specific Essence language features, which should be useful over the course of rewriting the conjure tool stack in Rust


## Usage

> This is heavily WIP and I am planning to make this more usable in the future.
> Eventually, this will be a Flask web server to host the web page, a better frontend (to make it searchable, sortable, etc), and the page will auto-update on changes to the relevant Essence example repos

For now, though:

- Put paths to conjure directory and Essence file directory in .env
- Run the main.py file
- See the generated HTML file


## ToDo

- [x] Get basic stats in JSON format
- [x] Get basic stats as HTML table
- [ ] Table sorting
- [x] Code refactoring
- [ ] Documentation
- [ ] Show/Hide table rows/columns
- [ ] Web server for hosting the HTML page
- 🏗️ GitHub Actions integration
- [x] Extra stats, e.g. file line count
- [ ] Sorting using these stats


------------------------------------------

- Georgii Skorokhod and Hannah Zheng, 2023
- University of St Andrews
- Developed as part of a Vertically Integrated Project by Ozgur Akgun et al
- (See [main repos](https://github.com/conjure-cp))
27 changes: 27 additions & 0 deletions tools/essence-feature-usage-stats/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from pathlib import Path

from dotenv import load_dotenv

from stats.essence_stats import EssenceStats
from web.server import create_server

ENV_PATH = Path("./.env").resolve()
load_dotenv(dotenv_path=ENV_PATH)

KEYWORD_BLOCKLIST = [x.strip() for x in os.getenv("KEYWORD_BLOCKLIST").split(",")]
ESSENCE_DIR = os.getenv("ESSENCE_DIR")
CONJURE_DIR = os.getenv("CONJURE_DIR")
ESSENCE_EXAMPLES_REPO = os.getenv("ESSENCE_EXAMPLES_REPO")
CONJURE_BIN = Path(CONJURE_DIR) / "conjure"

if __name__ == "__main__":
stats = EssenceStats(
ESSENCE_DIR,
CONJURE_BIN,
ESSENCE_EXAMPLES_REPO,
blocklist=KEYWORD_BLOCKLIST,
)

app = create_server(stats)
app.run()
Loading