-
Notifications
You must be signed in to change notification settings - Fork 11
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
Modules #274
Modules #274
Conversation
a9826dd
to
fc3ff0d
Compare
Hey @madmike200590! I am happy to see that you decided to jump in and continue. To be honest I anticipated the split to go much smoother. Turns out that I forgot that we need to split the API from implementations (which causes quite a number of changes), and there are some rough edges like the "Standard Library". |
Thank you for getting this off the ground! I've wanted to do something in this branch for some time now, but was tied up with PR #268.
Yeah, I also only fully realized that when looking at your changes. Still not sure about the nicest way to go, but here are my thoughts so far:
So what I'm trying to do now is to create a separate hierarchy of "Core" types, i.e. |
I see. Aggregates are definitely very useful as well! And yes, I also ran into the same troubles (public API and internal/core API). I wanted to resolve it with generics, but this is very tedious so I gave up. Your approach with mapping the public types to core types is very well doable! Give it a spin! I can't wait to add Alpha (just the solver, not the CLI) as a Gradle dependency in some application project for the first time 😆 |
@lorenzleutgeb, I have a gradle-noob-question that formed in my head while fiddling apart public and "core-internal" APIs... In order to achieve that, we need to have all relevant functionality exposed through interfaces in the
Since
In my opinion, this would be a problem, since it would make expose the types meant for internal use from The only way around this that I currently see is to have an additional module, let's call it
As far as I understand gradle dependency scopes, that would mean applications depending on Since I'm much more confident with maven than gradle,
|
Hmm, I am not sure whether Gradle is the correct layer to address this. I guess it should be JPMS which allows us to specify which packages of our module should be visible to the outside. And then being careful about marking classes |
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.
Adding this as intermediate review: some comments need addressing. Currently at 307/436 reviewed files and progressing. We are getting there. :-)
alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/common/CoreAnswerSet.java
Outdated
Show resolved
Hide resolved
...java/at/ac/tuwien/kr/alpha/core/common/fixedinterpretations/PredicateInterpretationImpl.java
Outdated
Show resolved
Hide resolved
alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/grounder/IndexedInstanceStorage.java
Outdated
Show resolved
Hide resolved
.../java/at/ac/tuwien/kr/alpha/core/programs/transformation/NormalizeProgramTransformation.java
Outdated
Show resolved
Hide resolved
alpha-core/src/main/java/at/ac/tuwien/kr/alpha/core/solver/DefaultSolver.java
Outdated
Show resolved
Hide resolved
alpha-core/src/test/java/at/ac/tuwien/kr/alpha/core/test/util/RuleParser.java
Outdated
Show resolved
Hide resolved
alpha-core/src/test/java/at/ac/tuwien/kr/alpha/core/test/util/RuleParser.java
Outdated
Show resolved
Hide resolved
…RuleParser.java Co-authored-by: Antonius Weinzierl <[email protected]>
…ndexedInstanceStorage.java Co-authored-by: Antonius Weinzierl <[email protected]>
Co-authored-by: Antonius Weinzierl <[email protected]>
…ransformation/NormalizeProgramTransformation.java Co-authored-by: Antonius Weinzierl <[email protected]>
…RuleParser.java Co-authored-by: Antonius Weinzierl <[email protected]>
…aultSolver.java Co-authored-by: Antonius Weinzierl <[email protected]>
…odPropagationEstimationStrategy.
Okay, I am done with the reviewing, all files viewed, finally. There are some of my comments in the last week that should be addressed and there is a git conflict with the |
Regarding the conflicting file
This is just because we have changes to I merged @madmike200590 do you have time to address the unresolved conversations this week? Otherwise just ping me and I'll have a go. |
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 would like to have a response for my old comment in alpha-cli-app/build.gradle.kts
but other than that, everything is fine!
Looks like we're good to merge, yay! @madmike200590 do you want to rebase this branch, to clean up the history? There are commits messages starting with "WIP" or "Intermediate commit". I'd like to avoid such commits on |
Great! While I see your point about the WIP commits, I don't really want to do a rebase only for that - especially since it's not like it'd be useful to try checking out "halfway done" versions of the modularization. If that's ok with everyone, I'd just go ahead and squash everything. |
I took the liberty to squash and merge, cutting down the merge commit message a lot. I used |
Great, thanks! It's a huge step forward and after all the time this took, it's great to have this finally "live" :D |
Codebase Modularization and API Streamlining
The idea of this PR is to make development of Alpha as well as applications using Alpha less cumbersome by partitioning the existing code into smaller, easier to understand packages, as well as providing a better public API for applications using Alpha.
Modules
The codebase is divided into the following modules: alpha-api, alpha-commons, alpha-core, alpha-solver and alpha-cli-app.
Module alpha-api
The api module consists mainly of interfaces specifying the objects API consumers (i.e. applications using Alpha) interact with, such as programs, rules, atoms, literals and answer sets. It also holds implementations of some configuration classes that are used across modules.
The rationale for specifying all API objects through interfaces and keeping these in a separate module is that it should be possible for implementations to be switched out or changed without affecting applications using the API.
Module alpha-commons
The commons module holds implementations of the "basic building blocks" of ASP programs, such as terms, atoms, literals, etc. which are used across all other modules. These implementations can be instantiated through factory methods (such as
Atoms.newBasicAtom(...)
), but are not visible to other modules themselves in order to avoid accidental dependencies on implementation-specifc behavior in code using those implementations.Module alpha-solver
This module provides an implementation of the
Alpha
interface which is the main API entry point for applications. It is separate from commons and core to avoid API clients having compile-time dependencies against types fromalpha-core
.alpha-core
is an "implementation" scoped, i.e. "internal" dependency ofalpha-solver
, which means that it is a runtime- but not a compile-time-dependency of code depending onalpha-solver
.Module alpha-core
alpha-core
implements Alpha's core functionality, i.e. program parsing, program transformations, grounding and solving. It depends onalpha-commons
andalpha-api
. While the core module is by far the largest, it is not intended for applications to directly depend onalpha-core
, but rather use it through the public API realized in the api, commons, and solver packages.Module alpha-cli-app
The cli-app module uses the public API to provide Alpha's functionality in a commandline application. It holds a
Main
class, commandline argument parsing and various utilities for use of Alpha as a commandline-application.